Google Analytics 4

Content Type: Widget
Categories: Utility,Data,Communication

Overview

This widget integrates Google Analytics 4 (GA4) into Mendix apps.Supports:Page tracking (automatic page views)

and Custom events (track user actions).

 

Documentation

1. Overview

  • This widget integrates Google Analytics 4 (GA4) into Mendix apps.
  • Supports:
    • Page tracking (automatic page views)
    • Custom events (track user actions)

 

2. Widget Modes

    • Page Tracker Mode: Place once in Master Layout[Mandatory]
    • Tracks all page views automatically
    • Custom Event Mode: Place on specific pages OR trigger via nanoflow
    • Sends event with parameters

 

3. Key Properties

General

  • mode → Page tracker / Custom event

Tracker Settings (Page tracking)

  • measurementId → GA4 ID
  • debugMode → true/false
  • anonymizeIp → GDPR compliance
  • consentRequired → enable cookie consent
  • consentGranted → attribute to allow tracking

Event Settings (Custom events)

  • eventName → e.g. button_click
  • eventTrigger → Page load / JS
  • eventParams → key-value pairs
  • triggerAction → optional nanoflow

Advanced

  • userRole → user segmentation
  • customDimension1 → extra data

 

4. JavaScript / Nanoflow Usage

  • Use global object:

window.mendixGA.trackEvent('event_name', { key: value });

  • Always check:

if (typeof window.mendixGA !== 'undefined')

  • Use GA4TrackEvent JS action in nanoflows

 

5. Common Issues

  • window.mendixGA undefined → Widget not on master layout
  • No events → Debug mode OFF / Consent not granted
  • Missing data → Measurement ID not set

 

Note: PII masking as a inbuilt feature to prevent the expose of sensitive info and managed by using ScrubPII

 

PII_KEYS = ["email", "phone", "name", "userid", "user_id", "password"];

 

The above are keys which will be managed by widget itself , drop if you need any particular PII masking is need. ok Now how does it work then?

 

// Someone passes this

mendixGA.trackEvent("login", { email: "user@example.com", page: "/home" })

;// scrubPii transforms it to

{ email: "[REDACTED]", page: "/home" }

 

 

 

Releases

Version: 1.1.1
Framework Version: 10.24.14
Release Notes:

New Changes

 

  1. Making the measurementId from static string to mendix attribute
  2. Stateless custom handler for live debug logs
  3. PII key masking for PII_KEYS = ["email""phone""name""userid""user_id""password"]; 
  4.  Using scrubPii to manage for GoogleTags 

example:

// Someone passes this

mendixGA.trackEvent("login", { email: "user@example.com", page: "/home" });

// scrubPii transforms it to

{ email: "[REDACTED]", page: "/home" }

Version: 1.0.0
Framework Version: 10.24.14
Release Notes:

Overview

  • This widget integrates Google Analytics 4 (GA4) into Mendix apps.
  • Supports:
    • Page tracking (automatic page views)
    • Custom events (track user actions)