Articles on: Settings & configurations

Integrate Google Tag Manager

The Google Tag Manager integration loads your Google Tag Manager (GTM) container on every published project on the Maglr domain you connect it to. Maglr then sends events and variables to the page's data layer, which you can use in GTM to send data to Google Analytics 4 or other tools. For more about GTM itself, see Google's Tag Manager help.


Google Tag Manager requires some technical expertise. Maglr gives no guarantee or support for the scripts you add to your projects through Google Tag Manager.


Creating a Google Tag Manager account and container


To use Google Tag Manager with Maglr, you need a GTM account with a web container. The container ID (it starts with GTM-) is what you connect to your Maglr domain.



To create an account and container in Google Tag Manager:


  1. Go to https://tagmanager.google.com/ and sign in with your Google account.
  2. Click Create Account.
  3. Under Account Setup, enter an account name and choose your country.
  4. Under Container Setup, enter a container name, for example your domain, and choose Web as the target platform.
  5. Click Create and accept the terms of service.


Image: creating an account in Google Tag Manager


After you create the container, copy its container ID (it starts with GTM-). The container ID is shown at the top of your GTM workspace. You paste it into your Maglr domain settings.


Image: copying the GTM-code in Google Tag Manager


Connecting Google Tag Manager to a Maglr domain


You connect a Google Tag Manager container to a Maglr domain with its container ID (for example GTM-XXXXXXX). Paste only the container ID, not the full installation snippet that GTM also offers: Maglr adds the GTM script to your published projects itself.


To connect Google Tag Manager to a domain:


  1. Go to Settings → Domain names.
  2. Click the domain you want to add tracking to.
  3. Scroll to Statistics & integration and turn on Google Analytics or GTM.
  4. Set Integration type to Google Tag Manager.
  5. Paste your container ID (for example GTM-XXXXXXX) into GTM code.
  6. Click Save changes.


All published projects on that domain now load your GTM container. A domain uses either Google Analytics or Google Tag Manager, not both. For the other settings in this section, see Statistics & integration settings for your domain.


Reading Maglr data with Data Layer Variables


Maglr pushes its data, such as the event category, action and label or the page title, to the data layer as keys like maglrCategory. To use a key in Google Tag Manager, create a Data Layer Variable for it. The Data Layer Variable Name must match the Maglr key exactly, including capitals. For all keys, see Maglr data layer variables.


To create a Data Layer Variable for a Maglr key, in Google Tag Manager:


  1. Go to Variables and click New under User-Defined Variables.
  2. Choose Data Layer Variable as the variable type.
  3. Enter the Maglr key, for example maglrCategory, as the Data Layer Variable Name.
  4. Name the variable and click Save. Giving it the same name as the key, for example maglrCategory, makes it easiest to recognise in tags.


Repeat these steps for each Maglr key you want to use. Tags refer to a variable by its own name in double curly brackets, for example {{maglrCategory}}.


Image: a Data Layer Variable in Google Tag Manager


Creating triggers for Maglr events


Every Maglr event, such as maglrUserEvent or maglrVirtualPageView, is a data layer event. In Google Tag Manager you catch it with a Custom Event trigger whose Event name matches the Maglr event name exactly, including capitals. For all event names, see Maglr data layer events.


To create a trigger for a Maglr event, in Google Tag Manager:


  1. Go to Triggers and click New.
  2. Choose Custom Event as the trigger type.
  3. Enter the Maglr event name, for example maglrUserEvent, as the Event name.
  4. Optional: to fire only for some events, choose Some Custom Events and add a condition, for example maglrCategory equals Video.
  5. Name the trigger and click Save.


Image: setting up a Trigger in Google Tag Manager


Sending Maglr events to Google Analytics 4


To send Maglr events to Google Analytics 4, create a Google Analytics 4 event tag in Google Tag Manager that fires on your Maglr trigger. This uses the Data Layer Variables and triggers described in the sections above.


To create a GA4 event tag for Maglr events, in Google Tag Manager:


  1. Go to Tags and click New.
  2. Choose Google Analytics: GA4 Event as the tag type.
  3. Enter your GA4 Measurement ID.
  4. Set the Event Name, for example {{maglrCategory}}.
  5. Add event parameters, for example maglr_action with the value {{maglrAction}} and maglr_label with the value {{maglrLabel}}.
  6. Under Triggering, choose your Maglr trigger.
  7. Click Save.


Tip: to tell Maglr events apart from your other events in Google Analytics, add a prefix to the event name, for example maglr-{{maglrCategory}}.


Image: setting up a GA4 Event Tag in Google Tag Manager


Testing and publishing your Google Tag Manager container


Test your Google Tag Manager setup on a published project, using GTM's preview mode. Maglr doesn't load your GTM container in its own previews of a project, so Maglr events don't show up there.


To test and publish your container:


  1. In Google Tag Manager, click Preview.
  2. Enter the published URL of a project on the domain you connected.
  3. Interact with the project, for example open pages or click links, and check that the Maglr events appear in the preview panel.
  4. When everything works, click Submit in Google Tag Manager to publish your container.



Maglr's own cookie consent doesn't stop your Google Tag Manager container from loading. When you turn on Activate cookie consent notification for a domain, the visitor's choice affects Maglr's own features, such as its statistics, its Google Analytics integration and YouTube and Vimeo videos, but not your GTM container. Tags in your GTM container fire whatever the visitor chooses, unless you limit them in GTM yourself.


Tags in your Google Tag Manager container fire even when a visitor rejects Maglr's cookie consent. If a tag needs consent, add a consent condition to its trigger in Google Tag Manager, for example MaglrCookieConsented equals true.


Maglr sends two data layer events for cookie consent:


  • maglrConsentChanged: sent when the visitor's choice is known, either on page load from a stored choice or when the visitor accepts or rejects. It carries the key maglrCookieConsented, which is true when the visitor accepted and false when they rejected.
  • maglrConsentRequested: sent only in Manual mode, when Maglr asks your own consent tool to show the consent request again.


To fire a tag only after consent, use a Custom Event trigger with Event name maglrConsentChanged and the condition maglrCookieConsented equals true. For how cookie consent works in Maglr, see Configure cookie consent.


Maglr data layer events


Maglr pushes these events to the data layer of a published project. In Google Tag Manager, catch each one with a Custom Event trigger whose Event name matches the name exactly.


Event

When Maglr sends it

maglrPageView

When the first page of a project loads.

maglrVirtualPageView

Each time the visitor goes to another page after the first.

maglrPageEvent

Once per page, when the page has finished preloading in the background.

maglrUserEvent

When the visitor interacts with the content, for example plays a video, opens a popup or clicks a link.

maglrInterfaceEvent

When the visitor uses the interface around the content, for example the overview page, navigation menu or side menu. Also sent once, 15 seconds after a project opens, if Maglr hasn't sent any other event in that time.

maglrConsentChanged

When the visitor's cookie consent choice is known or changes.

maglrConsentRequested

In Manual mode cookie consent, when Maglr asks your own consent tool to show the consent request again.


Maglr data layer variables


Maglr adds these keys to the events it pushes to the data layer of a published project. To use a key in Google Tag Manager, create a Data Layer Variable whose Data Layer Variable Name matches the key exactly, including capitals. Page keys, such as maglrIssueID, maglrPageTitle and MaglrCookieConsented, are added to an event when Maglr knows the current project and page.


Key

What it contains

Example

event

The Maglr event name.

maglrUserEvent

maglrCategory

The event category, on user and interface events.

Video

maglrAction

The event action, on user and interface events.

Play

maglrLabel

The event label, on user and interface events.

back-to-overview

maglrValue

An event value, on some events. This is often the project ID.

1234

maglrElementName

The name of the element that sent the event, on user events that come from a specific element.

Intro video

maglrElementID

The ID of the element that sent the event, on user events that come from a specific element.


maglrIssueID

The ID of the project.

1234

maglrSpreadID

The ID of the current page.

5678

maglrLanguage

The language of the project.

nl_NL

maglrPageType

The type of page. This is usually publication.

publication

maglrPageStatus

The loading status of the page: created, started, paused or stopped.

started

maglrReferenceTag

The page's Reference, only when one is set in the page settings.

pricing-page

maglrPagePath

The URL path of the page.

projectname/pagename

maglrPageURL

The full URL of the page.

https://www.domain.com/projectname/pagename

maglrPageTitle

The title of the page.

Introduction

maglrProjectTitle

The title of the project.

Annual report

MaglrCookieConsented

Whether the visitor accepted Maglr's cookie consent: true or false. It is also false before the visitor has made a choice, and when cookie consent is turned off for the domain. Note the capital M.

false

maglrCookieConsented

Only on the maglrConsentChanged event: true when the visitor accepted, false when they rejected. Note the lowercase m.

true


User event categories, actions and labels


Maglr sends a maglrUserEvent when a visitor interacts with the content of a published project. Each event has a category (maglrCategory), an action (maglrAction) and a label (maglrLabel). Values are case-sensitive in Google Tag Manager conditions.


In a published project, the label of a user event usually ends with the project and page ID, for example My popup :: (1234|5678). To match a label in a trigger condition, use contains or starts with instead of equals.


Category

Action

Label

Video

Play

<source>-<video ID>-<element name> for YouTube and Vimeo, <source>-<element name> for other videos

Audio

Play, Stop or End

Element name

Form

Submit

Form name

Popup

Open

Popup name

Popup

Close

Popup name

Link

Toggle-layer

Names of the elements shown or hidden, separated by commas

Link

Scene

Scene name

Link

Internal

URL path of the target page

Link

External

URL

Link

File

File name

Link

Reference

Reference name

Link

Element-action

Element name and action (see below)

Link

Scrollto

<link element name> -> <target element name>

Link

Interface

Interface link, for example home, back, previous_spread, next_spread, overview, close_level or menu.contact

Link

Social-link

Social network

Link

Postmessage

Message

Link

Multiple actions

Multiple actions

Link

Accessibility

Close_layer_keyboard

Slideshow

next, prev, or dot1, dot2 and so on

Element name

Scroll-depth

Position-desktop or Position-mobile

How far the visitor got on the page, as a number from 0 to 100 (see below)

Embeds

Embed element name

Value the embed sends


More about specific user events:


  • Video: events are sent only when a visitor starts a video manually. Autoplay videos don't send events.
  • Element-action: the label is the element name and the action, separated by a vertical bar without spaces. Actions include next, previous, restart, play and pause.
  • Scroll depth: the event is sent once, when the visitor leaves the page. Depending on the page, the depth is either rounded down to 0, 25, 50, 75 or 100 (anything past 90% counts as 100), or the percentage of the page's scenes the visitor has seen.
  • Form: a form submission is sent with category Form and action Submit. Depending on the page, it can arrive as a maglrUserEvent, as a maglrInterfaceEvent, or as both. Check in Google Tag Manager's preview mode which events your form sends, and use one event name in your trigger so each submission is counted once.
  • Element names are the names the elements have in the editor.


Interface event categories, actions and labels


Maglr sends a maglrInterfaceEvent when a visitor uses the interface around the content of a published project: the overview page, the viewer and the side menu. Each event has a category (maglrCategory), an action (maglrAction) and a label (maglrLabel). Values are case-sensitive in Google Tag Manager conditions.


Side-menu tab names, used as labels below, are spreads, sitemap, issues, info, contact, register, share, search, pdf and loggedin.


Category

Action

Label

Interface-overview

Open-sidemenu

Side-menu tab name, for example contact or search, or direct

Interface-overview

Open-category

Category name

Interface-overview

Change-language

Language abbreviation, for example nl_NL

Interface-overview

Open-legacy-issue

Issue name

Interface-overview

Logo-click

open-website or open_website

Interface-overview

Accessibility

use_skiplink

Interface-viewer

Open-sidemenu

Side-menu tab name, or sidemenu, overview or direct

Interface-viewer

Open-overview

back-to-overview or back_to_overview

Interface-viewer

Gate-activated

Form name

Interface-viewer

Gate-form-submitted

Form name

Interface-viewer

Gate-closed-manually

Form name

Interface-viewer

Cookie-consent

accept or reject

Interface-viewer

Accessibility

use_skiplink

Interface-viewer

Switch-audio

toggle

Interface-sidemenu

Open-tab

Side-menu tab name

Interface-sidemenu

Search-query

Search text the visitor submitted

Interface-sidemenu

Open-search-link

Title and ID of the page the visitor clicked in the search results, for example Introduction-5678

Interface-sidemenu

Share-tab

linkedin, facebook, twitter, email or whatsapp

Interface-sidemenu

Download-tab

download_complete_pdf or download_single_pdf

Interface-sidemenu

Open-contact-link

URL of the contact link

Interface-sidemenu

Contact-tab

Submit_contact_form or submit_form

Interface-sidemenu

Register-tab

Submit_register_form or submit_form

Interface-sidemenu

Loggedin-tab

logout

User-still-there?

No-interaction

15-seconds


The User-still-there? event is sent once, 15 seconds after a project opens, if Maglr hasn't sent any other event in that time. A page view also counts as an event, so you may rarely see it.


Frequently asked questions


Why don't I see Maglr events in Google Tag Manager when I preview my project in Maglr?


Maglr doesn't load your Google Tag Manager container in its own previews of a project. To test your setup, use the Preview button in Google Tag Manager and enter the published URL of a project on the domain you connected to GTM.



No. Maglr's cookie consent doesn't stop your Google Tag Manager container from loading, and tags in the container fire whatever the visitor chooses. To fire a tag only after consent, use a Custom Event trigger on the maglrConsentChanged event with the condition maglrCookieConsented equals true.


Can I use Google Analytics and Google Tag Manager on the same domain?


Not as two separate integrations. In a domain's Statistics & integration settings, Integration type is either Google Analytics or Google Tag Manager. To use both, choose Google Tag Manager and add a Google Analytics 4 tag to your GTM container.


Do autoplay videos send events to Google Tag Manager?


No. Maglr sends a video event (category Video, action Play) only when a visitor starts a video manually. Videos that play automatically don't send events.


Why does the Maglr event label end with numbers in brackets?


In a published project, Maglr adds the project ID and page ID to the end of the label of a user event (maglrLabel), for example My popup :: (1234|5678). To match these labels in a Google Tag Manager trigger condition, use contains or starts with instead of equals.

Updated on: 15/10/2026