Articles on: Share & analyse

Track embed events with GTM (inside your website)

A Maglr page embedded on your website can send its interaction events, such as clicks, video plays and form submissions, to your website's Google Tag Manager (GTM) dataLayer. Your GTM container can then use these events as triggers and send them to your own Google Analytics property. Separately, an embed that uses an iframe also runs the tracking set in the "Statistics & integration" settings of the project's domain.


Tracking inside the embed


A Maglr page embedded with an iframe runs on its own embed URL, embed.maglr.com/<code>, where the code is unique to each embed. This applies to every embed type except Automatic format (inject), which places the page directly in your website's page. Tracking inside an iframe embed uses the "Statistics & integration" settings of the domain the project is published on:


  • Standard Maglr statistics: Maglr's own statistics for the embed.
  • GA4 code or GTM code: your own Google Analytics or Google Tag Manager code, if you added one to that domain.


Page views and interaction events inside the embed are recorded on the embed URL, not on the URL of your website's page. A project that isn't published on a domain gets no GA4 or GTM tracking inside its embeds. If the project is published on more than one domain, the embed uses the settings of one of them, so give those domains the same tracking settings. To see the Maglr statistics for an embed, read Analyse embed statistics.


Sending embed events to your website's dataLayer


A Maglr page embedded on your website pushes its interaction events into your website's GTM dataLayer as the custom event maglrUserEvent. Your GTM container can use maglrUserEvent as a trigger and send the events to your own Google Analytics property, where they are recorded on your website's page.



The forwarded interaction events include clicks, links, video and audio, slideshows, forms, popups and scroll depth. Page views inside an iframe embed are not forwarded to your website's dataLayer. You find those page views in Maglr's embed statistics and in the tracking on the project's domain.


Requirements for forwarding embed events


A Maglr embed sends its events to your website's dataLayer only when all of these apply:


  • The embed shows a single page: you chose One specific page from this project when you created the embed code. An embed of the complete project doesn't send events to your website's dataLayer.
  • The complete embed code is on your website, including the <script> line. Without that line, the events don't reach your website's dataLayer.
  • Google Tag Manager is installed on the page of your website that holds the embed, so that page has a dataLayer.


Events with the Automatic format (inject) embed type


With the Automatic format (inject) embed type, the Maglr page doesn't run in an iframe: it becomes part of your website's page. Its events go directly into your website's dataLayer, as long as Google Tag Manager is installed on that page.


Setting up event tracking for an embedded page


To get the events of an embedded Maglr page into your website's GTM dataLayer:


  1. In the dashboard, open the project and click Share project in the sidebar, below the project thumbnail. You can also click ... on the project tile and select Share.
  2. Go to Embed code.
  3. Under "Choose a page or project", select One specific page from this project.
  4. Select the page you want to embed.
  5. Under "Choose an embed type", select an embed type: Automatic format (inject), Fixed format (manual) or Open in fullscreen layover. Automatic format (iframe) is available under Show legacy embed options. All of these send events to your website's dataLayer.
  6. Copy the complete embed code, including the <script> line, and paste it into your website.
  7. Make sure Google Tag Manager is installed on the page of your website that holds the embed.
  8. In your website's GTM container, add a trigger on the custom event maglrUserEvent.


For the full GTM setup, read Connect Maglr events with Google Tag Manager.




Frequently asked questions


Why don't I see page views from the embed in my own Google Analytics?


A Maglr page embedded with an iframe forwards only its interaction events to your website's GTM dataLayer, as the custom event maglrUserEvent. Page views inside the embed are not forwarded. They are recorded on the embed URL (embed.maglr.com/<code>) and show up in Maglr's embed statistics, and in the GA4 or GTM tracking set in the "Statistics & integration" settings of the project's domain.


Does event forwarding work when I embed the complete project?


No. Only an embed of a single page, created with One specific page from this project, sends its events to your website's GTM dataLayer. An embed of the complete project doesn't send events to your website's dataLayer.


What event name do I use in Google Tag Manager?


Use the custom event maglrUserEvent. A Maglr page embedded on your website pushes every interaction event into your website's dataLayer under this name, so a GTM trigger on maglrUserEvent picks them all up.


Do I need Google Tag Manager on my website for this to work?


Yes. A Maglr embed pushes its events into your website's dataLayer, which Google Tag Manager creates. If GTM isn't installed on the page that holds the embed, the events from the embed are not sent anywhere on your website.

Updated on: 20/10/2026