Add Google Tag Manager to EmDash
Google Tag Manager (GTM) needs two pieces of code: a loader script in the <head> and a <noscript>
fallback right after <body> opens. With Header & Footer Code you add each as its own snippet, and
the plugin puts them in the right places.
You need: the plugin installed, an EmDash Admin account, and a GTM web
container. Its ID looks like GTM-XXXXXXX.
1. Add the loader to the head
Section titled “1. Add the loader to the head”-
In Header & Footer Code, choose New snippet.
-
Paste the loader, replacing
GTM-XXXXXXXwith your container ID:<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-XXXXXXX');</script> -
Settings: Name GTM loader, Placement Head, Priority 5.
-
Save.
Google asks for the loader “as high in the <head> as possible”. A low priority puts it ahead of
your other head snippets.
2. Add the noscript fallback to the body
Section titled “2. Add the noscript fallback to the body”-
Choose New snippet again.
-
Paste the fallback with the same container ID:
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX"height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> -
Settings: Name GTM noscript, Placement Body start, Priority 5.
-
Save.
Body start is rendered by <EmDashBodyStart />, which belongs immediately after <body>. See
Theme setup.
3. Test the container
Section titled “3. Test the container”- In GTM, click Preview, enter your site’s URL, and check that Tag Assistant shows Connected and your tags fire.
- View the page source and search for your
GTM-ID. It should appear twice: once in the head, once just after<body>. - Remember to Submit (publish) the container in GTM. Preview only affects your own browser.
Common problems
Section titled “Common problems”| Symptom | Fix |
|---|---|
| Tag Assistant can’t connect | The loader snippet is off, the ID is wrong, or an edge cache serves old HTML. |
| Noscript iframe missing | Your layout doesn’t render <EmDashBodyStart />. |
| Data doubled in GA4 | GA4 is also added directly as a snippet. Remove one. |
| Consent tools fire after GTM | Give the consent snippet a lower priority than 5. See cookie consent. |
© 2026 Jithin Sebastian ·MIT License ·GitHub