CRO

Google Tag Manager Guide 2026: Setup, Triggers, Tags, Variables & GA4 Event Implementation

By Reviewed by Hawrry Bhattarai
August 21, 2026 19 min read
Contents
TL;DR — the short answer

Complete Google Tag Manager guide for 2026 — account setup, tags, triggers, variables, data layer, GA4 events, and the most common GTM tracking implementations with copy-pasteable code.

16 min read · CRO · Last updated July 2026

Quick answer: Google Tag Manager lets you deploy and manage tracking code on your site without developer involvement. The three concepts you must understand are Tags (what fires), Triggers (when it fires), and Variables (dynamic data). Master these three and you can implement virtually any tracking requirement through GTM’s interface.

Introduction

Before Google Tag Manager existed, adding a new tracking pixel to a website meant submitting a developer ticket, waiting for the next deployment window, and hoping nothing broke. A simple conversion event could take 2–3 weeks from request to live tracking.

GTM changed this. Marketers and analysts can now deploy, test, and publish tracking changes in hours rather than weeks — without touching site code after the initial GTM installation. This operational independence is why GTM became the industry standard for web tracking: over 53% of tracked websites use it (W3Techs, 2025).

This guide is the practitioner-level GTM reference you return to repeatedly. It covers setup, the conceptual framework, the most important tracking implementations, and the verification process that separates professional implementations from ones that drift silently out of sync.

What you’ll learn:
– The Tags, Triggers, Variables framework with real examples
– Installing GTM on WordPress, Shopify, and HTML sites
– Complete GA4 implementation via GTM
– The data layer: what it is, how to use it, and why it matters

Table of Contents

  1. What GTM Is and Why It Exists
  2. GTM Account and Container Setup
  3. The Three GTM Concepts: Tags, Triggers, Variables
  4. Installing GTM on Your Website
  5. Built-In Variables: The Pre-Made Data Sources
  6. Creating Your First GA4 Configuration Tag
  7. Creating GA4 Event Tags
  8. Trigger Types: The Complete Reference
  9. The Data Layer: Dynamic Data for GTM
  10. Testing in Preview/Debug Mode
  11. Publishing a Container Version
  12. Common GTM Implementations
  13. GTM Trigger Decision Tree Widget
  14. Tag Audit Checklist Widget
  15. FAQ
  16. Conclusion

1. What GTM Is and Why It Exists

Google Tag Manager is a tag management system (TMS) — a layer between your website and the tracking scripts (tags) that run on it.

Without GTM, every tracking pixel, analytics script, conversion tag, and chat widget is hardcoded into your website’s HTML. Changing anything requires code changes and deployments.

With GTM:
– One snippet of code is installed on your site (the GTM container code)
– All other scripts are deployed through GTM’s web interface as “tags”
– Changes are made in GTM and published — no site code changes required
– Tags can be tested in Preview mode before going live
– Every change is versioned, with rollback capability

GTM is not itself an analytics tool. It doesn’t collect data. It deploys tags that collect data. Think of it as the infrastructure layer that manages what tracking runs on your site, while GA4 is the analytics platform that stores and analyzes the data.

When to use GTM vs when not to:
Use GTM for: all tracking pixels, analytics tags, conversion events, remarketing tags, custom event tracking.
Do not use GTM for: core site functionality, site speed improvements, A/B testing code (use a dedicated testing platform), or anything that needs to run synchronously before the page renders.

2. GTM Account and Container Setup

Step 1: Create a GTM Account
Go to tagmanager.google.com → click “Create Account” → enter Account Name (your company name) → Country.

Step 2: Create a Container
Container Name: your website URL (e.g., ignitednepal.com)
Target Platform: Web (for websites), iOS, Android, or AMP as appropriate.
Click Create → Accept Terms of Service.

GTM Account vs Container hierarchy:
– One GTM Account per company/organization
– Multiple Containers under one account (one per website or app)
– Never put multiple unrelated sites in the same container — they would share the same published code

Container ID: Your container gets an ID in the format GTM-XXXXXXX. This is what you install in your site code.

Workspaces:
GTM uses Workspaces to manage parallel changes. The Default Workspace is sufficient for most teams. Multiple workspaces are useful when two teams are working on different tracking changes simultaneously and need to avoid conflicts.

User permissions:
Admin → User Management. Roles:
Publish: Can make and publish changes (give to senior analysts only)
Approve: Can approve changes but not publish
Edit: Can create and edit tags but not publish
Read: View-only access

3. The Three GTM Concepts: Tags, Triggers, Variables

Everything in GTM comes back to three concepts. Master these and the rest is configuration details.

Tags: What Fires

A Tag is a piece of code that GTM deploys on your site when specified conditions are met. Tags are the scripts that do the actual work — collecting data, firing pixels, enabling chat widgets.

Common tag types:
Google Analytics: GA4 Configuration — loads the GA4 library and sends the base configuration
Google Analytics: GA4 Event — fires a specific GA4 event (click, form submit, purchase)
Google Ads Conversion Tracking — fires when a conversion happens (though we recommend GA4 import instead)
Facebook Pixel — Meta’s tracking pixel
Custom HTML — any arbitrary HTML/JavaScript you need to inject
Custom Image — 1×1 pixel tracking images

Triggers: When It Fires

A Trigger defines the condition that causes a tag to fire. Without a trigger, a tag never runs.

Trigger basics:
– Every tag must have at least one trigger
– A tag fires when its trigger condition is true
– Multiple tags can share the same trigger
– One tag can have multiple triggers (fires if ANY trigger condition is met)

Trigger types (covered in depth in section 8):
– Page View / DOM Ready / Window Loaded
– Click — All Elements / Click — Just Links
– Form Submission
– Custom Event (from data layer)
– Scroll Depth
– Element Visibility

Variables: Dynamic Data

A Variable is a placeholder for a value that changes dynamically. Instead of hardcoding a product name or form ID into your tag, you reference a variable that pulls the value at runtime.

Variable types:
Built-in Variables: Pre-configured by GTM (Page URL, Click Text, Form ID, etc.)
Data Layer Variables: Pull values pushed to window.dataLayer
JavaScript Variables: Read any JavaScript value from the page
Lookup Tables: Map one value to another (e.g., map page path to section name)
Constant: A fixed value stored in GTM (like your GA4 Measurement ID)

4. Installing GTM on Your Website

GTM requires two code snippets: one in <head> and one in <body>. Both are available in GTM → Admin → Install Google Tag Manager.

Standard HTML installation:



WordPress installation:
1. Plugin method (recommended): Install “GTM4WP” plugin by Thomas Geiger → enter Container ID → set Placement to “Footer” (or “Header” for better accuracy) → Save. This plugin correctly handles WordPress page types and adds GTM to all pages.
2. Manual method: Add the head snippet to your theme’s header.php inside the <head> tag, and the body snippet to footer.php immediately after <body>. Works but breaks on theme updates.

Shopify installation:
Admin → Online Store → Themes → Actions → Edit Code → theme.liquid. Add the head snippet after the opening <head> tag and the body snippet after the opening <body> tag. Save.

Note: Shopify’s checkout pages require Shopify Plus to customize with GTM. Standard Shopify plans only allow GTM on storefront pages, not the checkout flow (for checkout tracking, use Shopify’s native Google Ads integration or Elevar).

Squarespace installation:
Settings → Developer Tools → Code Injection → paste head snippet in Header → paste body snippet in Footer. Note: this injects across all pages.

Verification:
After installation, open your site in a browser, right-click → View Page Source, and search for “GTM-XXXXXXX”. You should see the container ID in both the <head> and <body> code. Then check your GTM → Workspace → Preview to confirm GTM is loading on the site.

5. Built-In Variables: The Pre-Made Data Sources

GTM comes with built-in variables that capture common page and interaction data automatically. Enable them in Variables → Built-In Variables → Configure.

Essential built-in variables to enable:

Variable What It Returns Use For
Page URL Full URL of current page Page-based triggers, URL parameters
Page Path URL path without domain Trigger based on specific page
Page Hostname Domain only Multi-domain setups
Click Element The DOM element that was clicked Identify exactly what was clicked
Click Classes CSS classes on clicked element Trigger on elements with specific class
Click ID ID attribute of clicked element Identify buttons/links by ID
Click Text Text content of clicked element Trigger on specific link text
Click URL href value of clicked link Identify outbound links
Form Element The form DOM element Identify which form was submitted
Form ID id attribute of the form Trigger on specific form
Form Text Text content of the submit button Identify form by button label
Scroll Depth Threshold % or pixel depth of scroll Trigger at scroll milestones

6. Creating Your First GA4 Configuration Tag

The GA4 Configuration Tag loads the GA4 library and sends the base page_view event. This is the foundational tag that all GA4 Event tags depend on.

Steps:
1. Tags → New → Tag Configuration → Google Analytics: GA4 Configuration
2. Measurement ID: Enter your GA4 Measurement ID (G-XXXXXXXXXX). Best practice: create a Constant variable named “GA4 Measurement ID” with this value, then reference the variable — easier to update if the ID changes.
3. Fields to Set (optional): Add user_id, user properties, or consent mode parameters
4. Advanced Settings: leave defaults (tag firing priority 0, fire once per page)
5. Triggering → All Pages
6. Name: “GA4 Configuration — [Your Site]”
7. Save

Important: This tag fires once per page and establishes the GA4 session. All GA4 Event tags should reference this Configuration tag (not hardcode the Measurement ID again) so they use the same GA4 instance.

Send page_view setting:
The GA4 Configuration tag has a setting “Send a page view event when this configuration loads.” Keep this enabled for standard sites. Disable it only for Single Page Applications where you handle page_view events manually through history state changes.

7. Creating GA4 Event Tags

For each custom event you want to track, create a GA4 Event tag:

  1. Tags → New → Tag Configuration → Google Analytics: GA4 Event
  2. Configuration Tag: Select your GA4 Configuration tag from the dropdown
  3. Event Name: Enter the event name in snake_case (e.g., contact_form_submit)
  4. Event Parameters: Add key-value pairs for any additional data
    – Key: form_id, Value: {{Form ID}}
    – Key: page_path, Value: {{Page Path}}
  5. User Properties (optional): User-scoped data that persists across sessions
  6. Triggering: Select or create the trigger that defines when this event fires
  7. Name: “GA4 Event — [Event Name]” (e.g., “GA4 Event — Contact Form Submit”)
  8. Save

Naming conventions:
– Tags: “GA4 Event — [Event Name]”
– Triggers: “[Trigger Type] — [What It Detects]” (e.g., “Form Submission — Contact Form”)
– Variables: “[Variable Type] — [Variable Name]” (e.g., “DLV — ecommerce.value”)

Consistent naming makes auditing your GTM workspace fast and prevents the common problem of duplicate tags with unclear purposes.

8. Trigger Types: The Complete Reference

Page View Triggers

Page View: Fires when the browser begins loading a page. Earliest possible fire point.
DOM Ready: Fires when HTML has loaded but external resources may still be loading. Good for tags that need to read DOM elements.
Window Loaded: Fires after all resources (images, scripts) have loaded. Use for tags that need the full page to be ready.

When to use: GA4 Configuration tag uses “All Pages” Page View. Any tag that reads DOM content uses DOM Ready or Window Loaded.

Click Triggers

Click — All Elements: Fires on click of any DOM element. Use when you need to detect clicks on buttons, divs, or other non-link elements.
Click — Just Links: Fires only on <a> tag clicks. Provides the link URL automatically. Use for outbound link and internal link tracking.

Condition filters: Add “Some Clicks” conditions to filter which clicks fire the trigger:
– Click URL contains “tel:” → phone number clicks
– Click URL contains “.pdf” → PDF downloads
– Click Classes contains “btn-primary” → primary button clicks
– Click ID equals “hero-cta” → specific button by ID

Form Submission Trigger

Fires when a form is submitted. GTM attempts to intercept the submission event.

Important caveat: GTM’s form submission trigger does NOT work on all forms. AJAX-submitted forms, forms inside iframes (e.g., embedded HubSpot, Typeform), and forms that don’t use standard HTML form submit events may not trigger this. For those, use Custom Event triggers with data layer pushes from the form library’s callback.

Settings:
– “Wait for tags” + “Check Validation”: ensures tags fire after form validation passes, not on failed submissions

Custom Event Trigger

Fires when a specific event name is pushed to the data layer. This is the most reliable trigger type for custom implementations.

window.dataLayer.push({ event: "booking_completed" });

GTM Custom Event trigger with Event Name = “booking_completed” catches this push.

Use custom event triggers for: ecommerce events, form completions on AJAX forms, third-party widget callbacks, any event where a data layer push is under your control.

Scroll Depth Trigger

Fires at specified page scroll percentages (10%, 25%, 50%, 75%, 90%) or pixel depths.

Enable built-in scroll variables first (Scroll Depth Threshold, Scroll Depth Units).

Use for: tracking content engagement depth, differentiating “skimmers” from “readers,” triggering CTAs after specific scroll depth.

Element Visibility Trigger

Fires when a specific DOM element enters the viewport. More precise than scroll depth for tracking whether specific content sections are seen.

Use for: tracking whether a pricing table was seen, whether a testimonial section was viewed, whether an important CTA was in the viewport.

9. The Data Layer: Dynamic Data for GTM

The data layer is a JavaScript array (window.dataLayer) that acts as a communication channel between your website’s code and GTM. It lets your site pass structured data to GTM, which GTM tags can then use as parameters.

Why the data layer exists:
GTM can read page URLs and click attributes from the DOM, but it cannot reliably read dynamic business data like product prices, user IDs, cart totals, or order IDs directly from the page (these may not be visible in the HTML). The data layer provides a structured, reliable way to pass this data.

Basic data layer push:

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  event: "add_to_cart",
  ecommerce: {
    currency: "USD",
    value: 49.99,
    items: [{
      item_id: "SKU-123",
      item_name: "Blue Widget",
      price: 49.99,
      quantity: 1
    }]
  }
});

Reading data layer values in GTM:
Create a Data Layer Variable in GTM:
– Variable type: Data Layer Variable
– Data Layer Variable Name: ecommerce.value
– This reads the value property inside the ecommerce object from the data layer push

Data Layer Variable naming for nested objects:
Use dot notation: ecommerce.items.0.item_name reads the first item’s name.

The ecommerce null push:
Always push { ecommerce: null } before a new ecommerce data layer push to clear previous ecommerce data:

window.dataLayer.push({ ecommerce: null }); // Clear
window.dataLayer.push({ event: "purchase", ecommerce: { ... } }); // Push new

10. Testing in Preview/Debug Mode

Never publish a GTM container change without testing it in Preview mode. This is the most important professional discipline in GTM work.

Enabling Preview:
In GTM workspace → click “Preview” button (top right) → enter your website URL → click “Connect.”

GTM opens your site in a new tab with the GTM debug panel at the bottom. The debug panel shows:

  • Summary: All tags that fired, fired on condition, and did not fire for each event
  • Tags: Detail view of each tag — which trigger fired it, which variables it read
  • Variables: All variable values at the time of the event
  • Data Layer: The data layer at each point in time

What to verify in Preview:

  1. GA4 Configuration tag fires on All Pages — should appear in “Tags Fired” on every page
  2. Event tags fire on the correct trigger — click your CTA button, verify the tag fires; fill in a form, verify form submission tag fires
  3. Variables contain correct values — not “undefined”, not empty string
  4. No unexpected tags firing — check “Tags Fired” carefully for tags that should not fire
  5. GA4 DebugView — in GA4 Admin → DebugView, your Preview session appears and shows all events in real time

Debugging common issues:

  • Tag in “Tags Not Fired”: the trigger condition was not met. Check trigger conditions carefully.
  • Variable shows “undefined”: the data source (DOM element, data layer key) was not found. Verify the element exists and the variable name is correct.
  • Tag fires multiple times per page: duplicate triggers or multiple tags with overlapping triggers. Review all tags for this event.

11. Publishing a Container Version

When testing is complete:
1. Click “Submit” (top right in GTM workspace)
2. Select “Publish and Create Version”
3. Version Name: descriptive label (“GA4 Contact Form Tracking” or “July 2026 — Ecommerce Events”)
4. Version Notes: describe what changed, why, and who made the changes
5. Click “Publish”

Version management:
GTM maintains a complete history of every published version. To roll back: Admin → Container Versions → find the previous version → click “…” → Restore.

Staging vs Production:
For high-traffic or high-stakes sites, consider using GTM environments. Admin → Environments. Create a Staging environment linked to your staging site, publish there first, verify, then publish to Production. This prevents a broken container from affecting live revenue.

12. Common GTM Implementations

Implementation 1: GA4 Purchase Event

Trigger: Custom Event, event name = “purchase”
Data Layer Push (on order confirmation page):

window.dataLayer.push({ ecommerce: null });
window.dataLayer.push({
  event: "purchase",
  ecommerce: {
    transaction_id: "ORDER-001",
    value: 99.99,
    tax: 8.99,
    shipping: 5.00,
    currency: "USD",
    items: [{ item_id: "SKU-1", item_name: "Product", price: 99.99, quantity: 1 }]
  }
});

GA4 Event Tag: Event Name = purchase, enable “Send Ecommerce data” from Data Layer.

Implementation 2: Outbound Click Tracking

Trigger: Click — Just Links, fires on “Some Clicks,” condition: Click URL does not contain your domain
GA4 Event Tag: Event Name = outbound_click, Parameter: link_url = {{Click URL}}, link_text = {{Click Text}}

Implementation 3: Scroll Depth Tracking

Variables: Enable Scroll Depth Threshold and Scroll Depth Units
Trigger: Scroll Depth, Percentage, 25%, 50%, 75%, 90%
GA4 Event Tag: Event Name = scroll_depth, Parameter: scroll_depth_threshold = {{Scroll Depth Threshold}}

Implementation 4: Form Submission Tracking

Trigger: Form Submission, wait for tags, check validation, fires on Some Forms, Form ID equals “contact-form”
GA4 Event Tag: Event Name = contact_form_submit, Parameter: form_id = {{Form ID}}

Implementation 5: Phone Click Tracking

Trigger: Click — All Elements, fires on Some Clicks, Click URL contains “tel:”
GA4 Event Tag: Event Name = phone_call_click, Parameter: phone_number = {{Click URL}}

13. GTM Trigger Decision Tree Widget

GTM Trigger Selector

Describe what you want to track and get the right trigger type

14. Tag Audit Checklist Widget

GTM Tag Audit Checklist

Audit your GTM container for quality and maintainability

0 of 20 checks complete

FAQ

Q1: Do I need to update my GTM container after it’s installed?
The GTM container code on your site does not change — it always loads the latest published container from Google’s CDN. You update tags, triggers, and variables within GTM’s interface and publish; the site code only needs to be changed once during initial installation (or never again if it was installed correctly).

Q2: Does GTM slow down my website?
GTM adds a small amount of JavaScript overhead. The GTM container snippet itself is async (does not block page rendering). Tags that fire synchronously can add loading time. The net performance impact of a well-configured GTM container is typically under 50ms — negligible. A poorly configured GTM with 30+ tags firing simultaneously, however, can meaningfully impact Core Web Vitals.

Q3: Can I use GTM with WordPress website builders like Elementor or Divi?
Yes. Install GTM via the GTM4WP plugin (works with all WordPress themes including page builders). The plugin handles proper placement in the head and body, and supports WooCommerce data layer pushes for ecommerce tracking.

Q4: What happens if I publish a broken container?
A broken container can prevent tags from firing (causing tracking gaps) or in extreme cases inject JavaScript errors that affect site functionality. This is why Preview mode testing before every publish is non-negotiable. If a broken version is published, roll back immediately: Admin → Container Versions → find the previous working version → Restore.

Q5: Can GTM track users across subdomains?
Cross-subdomain tracking requires configuration in both GTM and GA4. In GTM: in your GA4 Configuration tag, add the field linker and in GA4: Admin → Data Stream → Configure tag settings → Configure your domains → add all subdomains. This ensures the user’s client ID (stored in the _ga cookie) is passed across subdomain boundaries.

Q6: Should I use one GTM container for all my websites?
No. Each website should have its own GTM container. Sharing containers creates a situation where a tag intended for Site A fires on Site B. The only exception: if two domains are treated as the same property in GA4 (cross-domain tracking), they can share a container — but they must share the same GA4 property as well.

Conclusion

Google Tag Manager is the professional standard for web tracking for good reason: it gives marketers and analysts operational independence, provides version control for tracking changes, and makes tag deployment faster and safer than direct code changes.

The discipline that separates professional GTM use from amateur use:
– Test every change in Preview mode before publishing
– Name every tag, trigger, and variable descriptively
– Write version notes for every publish
– Audit your container quarterly for stale or duplicate tags

A GTM container that grows organically without structure becomes a liability — full of mystery tags no one remembers creating, redundant triggers, and untested configurations. Keep it organized from the start.

Need a GTM setup or audit? The Ignited Nepal analytics team builds and audits GTM containers — clean architecture, correct event tracking, and a documented system your team can maintain. Get started at ignitednepal.com/cro/

Written by the Ignited Nepal team. ignitednepal.com

NR

Article by

Niraj Raut

Head of Search at Ignited Nepal. Drove 340% organic traffic growth for EzyDog (Australia), 4× revenue for The Turf Man (Australia), and 120% month-on-month traffic growth for ThemeGrill (Nepal). Keynote speaker at WordCamp Nepal 2023 and verified WordPress.org open-source contributor.