Google Tag Manager and GA4

mado never loads Google and never sets a cookie. Instead the embed tells the page it sits on what happened, and your own tag records it under your own consent settings.

Turn it on

Add data-analytics="datalayer" to the embed element. In Studio, tick “Send events to Google Tag Manager” in the embed dialog and the snippet gets it for you.

<div data-mado="your-demo-slug" data-analytics="datalayer"></div>
<script async src="https://mado.show/p/loader.js"></script>

The loader listens to messages from its own demo only and pushes them to window.dataLayer (created if the page has none). It loads nothing and stores nothing.

The events

  • mado_start — the demo loaded on the page (the loader loads it as it nears the screen, so this counts loads, not clicks).
  • mado_step — a step was shown. Carries the step id, its name and the demo.
  • mado_cta — the call to action was clicked.
  • mado_lead — the lead form was sent. The fields the visitor typed are never included, only the fact that it happened.
  • mado_complete — the demo reached its last step.

Each push looks like this:

{
  event: 'mado_step',          // mado_start, mado_step, mado_cta, mado_lead, mado_complete
  mado_demo: 'your-demo-slug',
  mado_step: 's3',             // the step's id
  mado_step_name: 'Open the invoice list'
}

Tag Manager

Create a Custom Event trigger with the event name mado_step (or a regular expression, ^mado_, for all five). Create data layer variables for mado_demo, mado_step and mado_step_name, and use the trigger on a GA4 Event tag, with {{Event}} as its event name and the variables as event parameters.

GA4 without Tag Manager

If you use gtag.js without Tag Manager, a dataLayer push does not reach GA4 by itself. Leave data-analytics off and send the events from the demo's messages instead. In GA4, register mado_step_name and the others as custom dimensions to see them in reports.

<script>
  // gtag.js does not read plain dataLayer pushes, so listen to the demo's messages instead.
  window.addEventListener('message', function (e) {
    var f = document.querySelector('[data-mado="your-demo-slug"] iframe');
    var d = e.data;
    if (!f || e.source !== f.contentWindow || !d || typeof d.type !== 'string') return;
    if (!/^mado:(start|step|cta|lead|complete)$/.test(d.type)) return;
    gtag('event', d.type.replace(':', '_'), {
      mado_demo: d.demo, mado_step: d.step, mado_step_name: d.name
    });
  });
</script>

An iframe without the loader

If your platform only allows an iframe, the same messages arrive on the page. About ten lines do what the loader does:

<script>
  window.addEventListener('message', function (e) {
    var f = document.getElementById('mado-demo');   // your <iframe id="mado-demo" src="https://mado.show/e/your-demo-slug">
    var d = e.data;
    if (!f || e.source !== f.contentWindow || !d || typeof d.type !== 'string') return;
    if (!/^mado:(start|step|cta|lead|complete)$/.test(d.type)) return;
    (window.dataLayer = window.dataLayer || []).push({
      event: d.type.replace(':', '_'),
      mado_demo: d.demo, mado_step: d.step, mado_step_name: d.name
    });
  });
</script>

With data-inline="true" the player runs in your page and fires bubbling DOM events of the same names (mado:step and so on) that the loader forwards the same way.

Privacy

mado never loads Google or sets cookies. Your tag records these events, if it does, under your own consent banner. A step name is sent as the visitor saw it, so a name personalised with data-vars carries the values you put there. mado's own analytics stay cookie-free either way. See Privacy in the embed.