Google Analytics 4
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 IDdebugMode→ true/falseanonymizeIp→ GDPR complianceconsentRequired→ enable cookie consentconsentGranted→ attribute to allow tracking
Event Settings (Custom events)
eventName→ e.g.button_clickeventTrigger→ Page load / JSeventParams→ key-value pairstriggerAction→ optional nanoflow
Advanced
userRole→ user segmentationcustomDimension1→ 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
New Changes
- Making the measurementId from static string to mendix attribute
- Stateless custom handler for live debug logs
- PII key masking for PII_KEYS = ["email", "phone", "name", "userid", "user_id", "password"];
- 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" }
Overview
- This widget integrates Google Analytics 4 (GA4) into Mendix apps.
- Supports:
- Page tracking (automatic page views)
- Custom events (track user actions)