What You Will Learn
- What GTM is, how it works, and why it is the recommended tag management approach
- How to create a GTM account and container and install the container snippet
- The three types of GTM objects — Tags, Triggers, and Variables — and how they work together
- The most common trigger types and when to use each
- Built-in and user-defined variables — Data Layer variables for advanced implementations
- How to use Preview mode to test tags before they go live
- How publishing and version history work — and why versioning matters
- The complete workflow for deploying GA4 Configuration and GA4 Event tags via GTM
- How to implement custom events via GTM without touching site code
- GTM best practices for naming, organisation, and workspace management
What Google Tag Manager Is
Google Tag Manager is a tag management system — a platform that deploys and manages JavaScript tags (tracking scripts) on a website through a web interface, without requiring changes to the website's source code for each tag deployment. Instead of embedding each analytics or marketing tag directly in the page HTML, you embed a single GTM container snippet, and GTM loads all other tags from the cloud when the page loads.
The three-way separation GTM creates is its primary value: the website developer installs the container once; the analytics or marketing team manages tags, triggers, and variables through the GTM interface; and the live site is only affected when changes are published through GTM's formal publication workflow. This separation prevents the common problem of marketing teams accumulating dozens of hard-coded script tags in page templates — tags that are often forgotten, conflicting, or slowing page load — while giving the team the agility to implement tracking changes without development tickets.
Google Tag Manager is free for standard use. GTM 360 (the enterprise version, included in Google Marketing Platform 360) adds features like SLA guarantees and additional workspace collaboration, but the standard free version is sufficient for the vast majority of implementations.
Container Setup and Installation
Create a GTM account at tagmanager.google.com. Within the account, create a container for the specific website or app (containers are the per-website units — one container per domain). Container types: Web (for websites), iOS app, Android app, AMP, and Server (for server-side tagging).
After creating a web container, GTM provides the container snippet — two blocks of code. The first block (a <script> tag) goes in the <head> of every page, as high as possible. The second block (a <noscript> tag) goes immediately after the opening <body> tag. Both blocks are necessary — the noscript tag provides basic functionality for the small proportion of users with JavaScript disabled.
In most CMS platforms, the container snippet is added to a global template or header/footer partial — ensuring it appears on every page. This is a one-time developer task; after this, no further developer involvement is needed for tag changes.
Tags
Tags are the code snippets that GTM executes — the actual tracking scripts or pixels. GTM provides built-in tag templates for common services (Google Analytics, Google Ads, Floodlight, Criteo, and many others) and supports custom HTML or custom JavaScript tags for any third-party service without a native template.
Common tag types
| Tag Type | Use Case |
|---|---|
| Google Tag (GA4) | The base GA4 configuration tag — establishes the GA4 connection and passes configuration settings |
| GA4 Event | Fires a specific GA4 event with defined parameters when a trigger fires |
| Google Ads Conversion Tracking | Records a Google Ads conversion when a trigger fires (e.g. thank-you page load) |
| Google Ads Remarketing | Adds users to Google Ads audience lists based on page visits or events |
| Custom HTML | Any third-party script or pixel that does not have a native GTM template |
| Custom Image | 1×1 pixel image requests (some legacy third-party tracking uses this format) |
Triggers
Triggers define when a tag fires — the condition that causes tag execution. Every tag must have at least one trigger. Without a trigger, the tag never fires.
Common trigger types
- Page View. Fires when a page loads. Sub-types: Page View (fires when DOM begins loading), DOM Ready (fires when DOM is fully parsed), Window Loaded (fires when all resources including images are loaded). Most GA4 page_view tags use the Page View trigger.
- All Pages. A specific Page View trigger that fires on every page — used for the GA4 Configuration tag that must be present on all pages.
- Click — All Elements / Click — Just Links. Fires when any element is clicked (All Elements) or specifically when a link is clicked (Just Links). Can be filtered by element class, ID, URL, or text. Used for tracking button clicks, CTA interactions, and link clicks.
- Form Submission. Fires when a form is submitted. Provides variables for the form ID and form target. Most reliable when used with the "Wait for tags" option to ensure tags fire before the form redirects to a new page.
- Custom Event. Fires when a specific custom event is pushed to the Data Layer (via dataLayer.push). This is how advanced GTM implementations receive events from the website's JavaScript and pass them to tags.
- Scroll Depth. Fires at configurable scroll depth thresholds (e.g. 25%, 50%, 75%, 90%). Provides more granular scroll tracking than GA4's Enhanced Measurement which only fires at 90%.
- Timer. Fires at configurable time intervals after a page loads. Used for time-on-page tracking or content engagement measurement.
Variables
Variables capture dynamic values that tags and triggers reference — the page URL, the clicked element's text, the form field values, or custom data passed from the website to GTM. GTM has two types of variables:
Built-in variables
GTM provides built-in variables for common values — Page URL, Page Path, Page Hostname, Referrer, Click Element, Click Classes, Click ID, Click URL, Click Text, Form Element, Form ID, Form Target, Scroll Depth Threshold, and others. Enable these in Variables → Configure.
User-defined variables
Create custom variables for values not covered by built-in variables. Common types:
- Data Layer Variable. Reads a value from the Data Layer — the JavaScript object (window.dataLayer) that the website uses to pass structured data to GTM. The Data Layer is how the website communicates dynamic information (logged-in user ID, transaction value, product category) to GTM without using visible page elements.
- JavaScript Variable. Reads the value of any JavaScript variable from the page's global scope.
- Cookie. Reads the value of a first-party cookie.
- Lookup Table. Maps one value to another — useful for translating page paths to readable content categories.
- Constant. A fixed value that does not change — useful for Measurement IDs, account numbers, and other stable configuration values shared across tags.
Preview and Debug Mode
Preview mode is GTM's testing environment — it allows you to see exactly which tags fire on any page and interaction before publishing changes to the live site. Click "Preview" in the top right of the GTM workspace and enter the website URL. GTM opens the site with a debug panel at the bottom of the browser.
The debug panel shows: every event that triggered (page views, clicks, scrolls, form submissions, custom events); which tags fired and which did not for each event; the reason a tag did or did not fire (trigger met / not met); and the values of all variables for each event. This level of detail makes it possible to validate every tag, trigger, and variable configuration before it goes live.
Always test in Preview mode before publishing any GTM change. Testing verifies: the tag fires when expected and not when unexpected; the correct event name and parameters are sent; variables are capturing the correct values; triggers are not over-firing (firing on unintended pages or interactions) or under-firing (failing to fire on intended interactions).
Publishing and Version History
After validating in Preview mode, changes are published by clicking "Submit." GTM requires a version name and description — use descriptive names ("Add GA4 purchase event - April 2026") rather than generic ones ("Update"). Each published version is permanently stored in GTM's version history.
Version history enables rollback: if a newly published change causes problems (a tag firing incorrectly, a tracking error, a page load issue), you can immediately publish a previous version to revert the live site to a known-good state. This rollback capability is one of the most valuable features of tag management — it eliminates the risk of breaking live site tracking with a bad tag change.
Deploying GA4 via GTM
The GA4 implementation via GTM requires two tag types:
1. Google Tag (GA4 Configuration)
Create a tag: New Tag → Google Tag → enter the Measurement ID (G-XXXXXXXXXX) from the GA4 data stream. Trigger: All Pages. This tag establishes the GA4 connection on every page. One of these per GA4 property in the container.
2. GA4 Event tags
For each custom event to track: New Tag → Google Analytics: GA4 Event → configure the Measurement ID (or reference the Measurement ID from a Constant variable), Event Name, and any event parameters. Trigger: the specific trigger for that event (form submission, button click, etc.).
Store the Measurement ID as a Constant variable (e.g. named "GA4 - Measurement ID") and reference this variable in both the Configuration tag and all Event tags. This means you only need to update the Measurement ID in one place if it ever changes — rather than updating every GA4 tag individually.
Custom Events via GTM
The most common GTM custom event workflow: define the trigger → create the GA4 Event tag → test in Preview mode → publish.
Example: tracking newsletter sign-up form submission
- Create trigger: Form Submission → fire on "Some Forms" → condition: Form ID equals "newsletter-form" (or the specific form ID). Enable "Wait for Tags" to ensure the tag fires before the page potentially reloads.
- Create GA4 Event tag: Event Name = "newsletter_signup"; add parameter "form_location" with value from the Page Path variable (to identify which page the form was on).
- Trigger: the Form Submission trigger created in step 1.
- Test in Preview mode: submit the form → verify "newsletter_signup" appears in the Debug panel with correct parameters → verify GA4 DebugView shows the event.
- Publish with descriptive version note.
GTM Best Practices
- Consistent naming conventions. Use a naming convention that communicates tag type, platform, and purpose in the name itself: "GA4 Event — Form Submit — Contact Form" is immediately clear; "Tag 15" is not. Apply the same convention to triggers and variables.
- Use folders to organise tags. Group tags by platform (Google Analytics folder, Google Ads folder, Facebook folder) or by function. GTM folders have no functional effect — they are purely organisational — but they dramatically reduce the confusion of managing large container implementations.
- Never publish without testing in Preview mode. No exceptions. Even a "small" change to an existing tag can produce unexpected effects that Preview mode would catch.
- Write descriptive version notes. Every published version should have a clear description of what changed, why, and who made the change. Version notes are the audit trail for your entire tag management history.
- Limit access appropriately. GTM user roles: Publish (highest — can publish to live site), Approve (can approve containers but not publish), Edit (can create and edit but not publish), Read (read-only). Restrict Publish access to trusted team members — a poorly tested tag that gets published can affect live site performance and data quality.
Authentic Sources
Every factual claim in this guide is drawn from official Google documentation, regulatory bodies, or platform-published technical specifications. No third-party blogs or marketing tools are used as primary sources. All content is written in our own words — we learn from official sources and explain them; we never copy.
Official GTM documentation on creating and installing a GTM container.
Official documentation on GTM tag types and tag configuration.
Official documentation on GTM trigger types and trigger configuration.
Official documentation on the GTM Data Layer — how to use it for advanced event and variable implementations.