Connect Maglr events with Google Tag Manager
Maglr pushes page views and visitor interactions in a publication to the Google Tag Manager (GTM) data layer. In GTM, you turn these events into variables, triggers and tags, and send them to Google Analytics 4 (GA4) or another tool. This article uses GA4 as the example; the same variables and triggers work for any tool you connect through GTM.
To set it up in GTM, you:
- create Data Layer Variables for the Maglr information you want to use
- create Custom Event triggers for the Maglr events you want to respond to
- create tags that send the events to GA4
- test the setup on your published publication
Before you start
Maglr only pushes events to a GTM container that is linked to your domain. In the settings of your domain, in the Statistics & integration section, switch on Google Analytics or GTM, set Integration type to Google Tag Manager and enter your GTM code. If you haven't done this yet, follow the steps in this article first.
Maglr events in the GTM data layer
Maglr sends each tracked action in a publication to the GTM data layer as an event. The event name is what you respond to in GTM: "if this event happens, then send this to GA4". For example, when a visitor clicks a link in a page, Maglr pushes a maglrUserEvent with the category, action and label of that click, and GTM can forward those to GA4.
Event names are case-sensitive. Use them exactly as written below.
Page events:
- maglrPageView: sent when the first page of a publication loads. GTM's built-in page view trigger already fires on this first load, so you don't need a separate trigger for it.
- maglrVirtualPageView: sent every time the visitor moves to another page in the publication. Maglr changes the page without reloading the browser, so this is a "virtual" page view.
- maglrPageEvent: sent once for each page when Maglr has loaded it, including pages it preloads in the background. Most setups don't need it, because it doesn't show which pages the visitor actually saw.
Interaction events:
- maglrUserEvent: sent when a visitor interacts with the content of a page, such as a link, video, slideshow, tab menu, accordion or stepper.
- maglrInterfaceEvent: sent when a visitor uses the navigation around the content, such as the overview page, navigation menu, side menu or cookie banner. Form submissions also arrive as a
maglrInterfaceEvent, with categoryForm, actionSubmitand the form name as label.
Consent event:
- maglrConsentChanged: sent when cookie consent is switched on for the domain and the visitor's choice is known or changes. It carries the variable
maglrCookieConsented(trueorfalse).
Variables Maglr sends with each event
Maglr events carry information about the page they happened on. maglrUserEvent and maglrInterfaceEvent also carry the category, action and label of the interaction. maglrConsentChanged only carries maglrCookieConsented. Use the variable names exactly as written; they are case-sensitive.
Variable | What it contains |
|---|---|
| The category of the interaction, for example |
| The action, for example |
| The label, for example the URL of a clicked link or the name of a form. For most interactions with page content, Maglr adds the project ID and page ID at the end. For a link to another page in the publication, the label is the path of that page instead. |
| For interactions with page content, the ID of the project. Most other events don't include it. |
| The name of the element the visitor interacted with, for element-level events |
| The ID of that element, for element-level events |
| The ID of the project |
| The ID of the current page |
| The language of the publication, as a locale such as |
| The type of page, for example |
| The status of the page: |
| The reference tag of the page, only when the page has one |
| The path of the page, without a leading slash, for example |
| The full URL of the page |
| The title of the page |
| The title of the project |
|
|
For example, a click on an external link in a page arrives with maglrLabel set to https://example.com :: (123|456), where 123 is the project ID and 456 is the page ID. maglrValue is then 123.
Creating Data Layer Variables in GTM
To use information from Maglr's data layer in a GTM tag, create a Data Layer Variable for each Maglr variable you need. The GA4 setup in this article uses maglrCategory, maglrAction and maglrLabel.
- In GTM, open your container and go to
Variables. - Under User-Defined Variables, click
New. - Choose the variable type
Data Layer Variable. - In
Data Layer Variable Name, enter the Maglr variable name exactly, for examplemaglrCategory. - Give the variable a name, for example
maglrCategory, and clickSave.

- Repeat these steps for
maglrAction,maglrLabeland any other Maglr variable you want to use.

Creating Custom Event triggers for Maglr events
A Custom Event trigger makes a GTM tag fire when a specific Maglr event arrives in the data layer. To send content and interface interactions to GA4, create one trigger for maglrUserEvent and one for maglrInterfaceEvent.
- In GTM, go to
Triggersand clickNew. - Choose the trigger type
Custom Event. - In
Event name, entermaglrUserEvent. The name is case-sensitive. - Leave the trigger on
All Custom Events. - Give the trigger a name and click
Save.

- Repeat these steps with the event name
maglrInterfaceEvent.
Sending Maglr events to Google Analytics 4
A GA4 Event tag in GTM sends a Maglr event to GA4, with the Maglr category, action and label as event parameters. You need the Data Layer Variables and Custom Event triggers for maglrUserEvent and maglrInterfaceEvent described above.
- In GTM, go to
Tagsand clickNew. - Choose
Google Analytics, thenGoogle Analytics: GA4 Event. - In
Measurement ID, enter your GA4 measurement ID (it starts withG-). - In
Event Name, enter a name for the event in GA4, for examplemaglr_user_event. - Under
Event Parameters, add three parameters:maglr_categorywith value{{maglrCategory}},maglr_actionwith value{{maglrAction}}andmaglr_labelwith value{{maglrLabel}}. - Under
Triggering, select the Custom Event trigger you created formaglrUserEvent. - Give the tag a name and click
Save. - Repeat these steps for a second tag with the Custom Event trigger you created for
maglrInterfaceEvent, for example with the event namemaglr_interface_event.
maglr_, so you can tell Maglr events apart from your other events in Google Analytics.GA4 only shows event parameters in its standard reports after you register them as custom dimensions in GA4, under Admin > Data display > Custom definitions.
Measuring page views in a Maglr publication
Maglr changes pages in a publication without reloading the browser. It changes the URL with the browser's history, which GTM sees as a History Change. To measure page views in GA4, your GTM container needs a Google tag with your GA4 measurement ID (it starts with G-). That Google tag counts these page changes as page views automatically when the GA4 enhanced measurement option "Page changes based on browser history events" is on, which it is by default.
If that option is off, use one of these methods to count each page change as a page view:
- a GA4 Event tag with the event name
page_viewon a trigger of typeHistory Change - a GA4 Event tag with the event name
page_viewon a Custom Event trigger formaglrVirtualPageView
Use only one method. If you combine enhanced measurement, a History Change trigger and a maglrVirtualPageView trigger, GA4 counts the same page view more than once.
Testing your GTM setup
GTM doesn't load on Maglr preview links, so test your tags on the published publication.
- In GTM, click
Preview. - Enter the URL of your published publication, not a Maglr preview link.
- Click through the publication and check in Tag Assistant that your tags fire on the Maglr events.
- In GA4, open the
Realtimereport orDebugViewto see the events arrive. - When everything works, click
Submitin GTM to publish your container.
Frequently asked questions
Which Maglr event do form submissions use?
Form submissions in a Maglr publication arrive in the GTM data layer as a maglrInterfaceEvent, not a maglrUserEvent. The category is Form, the action is Submit and the label is the name of the form. To track form submissions, use a Custom Event trigger for maglrInterfaceEvent.
Why don't I see any Maglr events when I test with a preview link?
GTM isn't loaded on Maglr preview links, so no events reach GTM or Google Analytics from a preview. Test your setup on the published publication: in GTM, click Preview and enter the URL of the live publication.
Does Maglr push events when a visitor hasn't accepted cookies?
Yes. Maglr loads your GTM container and pushes its events to the GTM data layer whether or not the visitor has accepted cookies. Maglr's cookie consent doesn't block GTM or the tags in it. To fire tags only with consent, add a condition to your triggers that MaglrCookieConsented equals true, or respond to the maglrConsentChanged event, which carries maglrCookieConsented (true or false). MaglrCookieConsented is true only after the visitor accepts cookies.
Do Maglr's own statistics still work when I use GTM?
Yes. Google Tag Manager works alongside Maglr's standard statistics. Connecting GTM doesn't change the Activate standard Maglr statistics switch in your domain's Statistics & integration settings.
Updated on: 20/10/2026