How to add tracking with Google Tag Manager, and when not to
Add an analytics tag through Google Tag Manager with a Custom HTML tag, pick the right trigger, send events from Tag Manager triggers, and know the trade-offs.
On this page
Google Tag Manager is a container for other tags. If it is already on your site, adding a new analytics tool through it means no change to the site's code. If it is not, adding it just to load one tag adds a layer you do not need.
This page covers adding a tag, the trigger that matters, sending events from Tag Manager, and the trade-offs.
Install Sporetag with Google Tag Manager
- In Sporetag, copy your tag from Set up your site.
- In Tag Manager, open your container. Click Tags, then New, and name it Sporetag.
- Click Tag Configuration and pick Custom HTML. Paste the tag into the HTML box.
- Under Triggering, pick Initialization - All Pages. Click Save.
- Click Submit, then Publish. Nothing runs until the container is published.
Custom HTML is the tag type for code a vendor gives you that Tag Manager has no template for (Google). Leave Support document.write off; the tag does not need it.
Why the Initialization trigger
Every web container has a built-in Initialization - All Pages trigger. It fires before the other page view triggers, except Consent Initialization (Google). An analytics tag should load as early as possible, so it counts visitors who leave fast and is ready before other tags send events.
Consent Initialization is for consent tools and consent defaults, not for analytics tags (Google). Google's own GA4 troubleshooting points to the same trigger order: a Google tag that fires late is a known cause of (not set) sources in GA4.
Checking it works
Tag Manager adds tags after the page starts loading, so a tool that reads your page's HTML, such as a "check my site" button, cannot see a tag inside Tag Manager. Check it instead:
- with Tag Manager's Preview mode, which shows each tag that fired on each page, and
- by opening your site and watching the analytics tool's real-time view.
Send events from Tag Manager triggers
Tag Manager's triggers (clicks, form submissions, element visibility, custom events from your site's data layer) can send events to any tool. For Sporetag, make another Custom HTML tag with one line, and fire it on the trigger:
<script>sporetag('Quote sent');</script>Use triggers that fire after the page has loaded, such as clicks, form submissions and data layer events, so the Sporetag tag is ready. Then make Quote sent a goal in Sporetag. This is the Tag Manager way to count actions the page itself does not expose; for no-code goals without Tag Manager, see goals without a developer.
Consent
If your consent tool runs in Tag Manager, it can tell other tags what the visitor chose. Sporetag's default Private mode stores nothing on the device. In 90-day tracking with Wait for consent on, fire a Custom HTML tag with sporetag('consent', true) on your consent tool's "accepted" trigger, and sporetag('consent', false) when the visitor declines. The legal side is in cookieless analytics and GDPR.
Trade-offs to know
- One more request before tags run. Tag Manager itself must load first. Pasting a tag straight into the page is simpler when you only have one or two tags.
- Blockers. If a visitor's blocker stops Tag Manager, every tag inside it stops with it.
- Publishing is a step people forget. Changes in a workspace do nothing until published.
- Access. Anyone with publish rights can change every tag on the site. Keep the list of publishers short.
Common questions
Can I add any analytics tool through Google Tag Manager?
Yes, with a Custom HTML tag, as long as the tool's tag works when added after the page starts loading. Most do.
Which trigger should an analytics tag use?
Initialization - All Pages, so it loads before other page view triggers. Keep Consent Initialization for your consent tool.
Why does my tag not show up after I added it in Tag Manager?
The container was not published, the trigger does not fire on that page, or a blocker stopped Tag Manager. Use Preview mode to see which.
Should I install Google Tag Manager just to add one tag?
Usually not. Paste the tag into your site's header instead. Tag Manager pays off when you manage several tags or need its triggers.
Sources
- Tag Manager Help: Custom tags, Page view triggers. Checked October 2026.
Spotted something wrong or out of date? Email hello@sporetag.com and we will fix it.