How to use the MasterPageTracker from the google Analytics widgets?

I want to use the MasterPageTracker from the Google Analytics widget for tracking 1 module.  In mendix Docs they say you need to add the MasterPageTracker in your master layout : “Typically, you want to start with the MasterPageTracker widget by adding it to your master layout.” When I put this widget in my masterlayout, I get an error that I need to move the widget into a data container, but its not possible to add a data or list view into a lay-out right? So whats the right way to use this widget?
2 answers

Do this for the snippet and make the resource-microflow return the currentuser:

Mind you: the MasterPageTracker is being replaced by their new version: GA4. This is not (yet) implemented in the Google Analytic-marketplace-widget. What you need to do for the GA4 variant is to open your project’s directory, open theme/index.html and add this to the head:

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src=""></script>
    window.dataLayer = window.dataLayer || [];
    function gtag() { dataLayer.push(arguments); }
    gtag('js', new Date());
    gtag('config', 'G-Youraccount');

and of course replace G-Youraccount with youraccount. Now you are ready for the next decade :-)


In order to add the MasterPageTracker to a layout, you have to create a Snippet that contains a dataview with the MasterPageTracker inside. Afterwards you can add the Snippet to the Layout.