Triggers: the "when" of tag management
A trigger in GTM is a rule that says: "fire this tag when these conditions are true." Every tag requires at least one trigger — without a trigger, a tag never fires. With a poorly configured trigger, a tag fires at the wrong time, on the wrong pages, or more times than intended.
GTM has several built-in trigger types:
Page View triggers fire when a page loads. The "All Pages" trigger fires on every page view. You can scope it more narrowly — "fires on page views where the URL contains /blog/" — to limit a tag to specific pages.
Click triggers fire when an element on the page is clicked. GTM listens for click events on the DOM and can be filtered by element ID, class, text content, or the URL the click leads to. "All Clicks" fires on every click. "All Links" fires only on clicks that navigate to a new URL. Both can be scoped with conditions.
Form triggers fire when a form is submitted. The "All Forms" trigger fires on every HTML form submission. Scoped form triggers filter by form ID, form action URL, or other form attributes.
Custom Event triggers fire when a specific event name is pushed to the data layer. This is the most powerful trigger type — it lets your website explicitly tell GTM "something important just happened" without relying on GTM to infer it from DOM observation.
Timer triggers fire on a schedule — every X seconds after page load. Useful for time-on-page milestones, but should be used carefully as they can inflate session data if misconfigured.
Element Visibility triggers fire when a specific element enters the viewport. Useful for tracking whether a key section of a page was actually seen, not just scrolled past.
Trigger conditions: where accuracy lives
A trigger fires "all the time" or "only when conditions are met." Conditions are the filters that scope a trigger to the right situations.
Common conditions: Page URL contains/equals/matches regex a specific value. Click Text equals a specific string. Click Classes contains a specific class name. Data Layer Variable equals a specific value.
The most important condition-writing discipline is specificity. "All Clicks" without conditions is almost never the right trigger — it fires on navigation links, image clicks, button clicks, and anything else that emits a click event. "Clicks on elements where Click ID equals contact-form-submit" is specific enough to be accurate.
Always ask: "What else could trigger this condition that I don't want to track?" If you can't think of a false positive, the trigger is probably specific enough.
Variables: the "what" that makes tags flexible
If triggers are the "when," variables are the "what." A variable captures a value at the time an event occurs and makes that value available to tags and trigger conditions.
GTM has built-in variables that are always available: Page URL, Page Hostname, Page Path, Referrer, Click URL, Click Text, Click Classes, Form Element (the form that was submitted), and several others. Enable these in the Variables panel — many are disabled by default.
Custom variables let you read any value from the page. The three most important custom variable types:
Data Layer Variables read values pushed to the data layer by your website. If your site pushes {'{'}'event': 'form_submit', 'form_name': 'contact'{'}'}, a Data Layer Variable configured to read form_name will return "contact" when the event fires.
DOM Element variables read the text or attribute value of a specific HTML element. Useful for reading form field values, product prices, or any text content that doesn't come through the data layer.
JavaScript Variable variables execute a JavaScript expression and return its value. For reading values from JavaScript objects on the page, reading cookies, or computing derived values.
The data layer: the proper way to pass information to GTM
The data layer is a JavaScript array that sits on your page and serves as the communication channel between your website's application code and GTM. Your site pushes events and associated data to it. GTM listens, fires triggers, and uses variables to extract the data.
The alternative to the data layer is DOM scraping — having GTM read values directly from the HTML. DOM scraping works but is fragile. If a developer changes a class name, an element ID, or the DOM structure, your tracking breaks silently. Data layer pushes are intentional and explicit — they're less likely to break on site changes because they're written by developers who know they're part of the tracking architecture.
A typical data layer push pattern for a form submission:
// In your application code, after form submission:
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'form_submit',
form_name: 'contact',
form_id: 'main-contact-form'
});
In GTM: a Custom Event trigger listening for the event name "form_submit," Data Layer Variables reading "form_name" and "form_id," and a GA4 event tag that sends those as parameters.
Testing everything in preview mode
GTM's preview mode is the single most important feature for anyone configuring triggers and variables. It opens a debug panel alongside your website showing every event that fires, which triggers activated on each event, and the values of every variable at each point.
Before publishing any container change, go through these steps in preview mode: trigger the action you're tracking, verify the correct trigger fired, verify the correct tag fired (and fired exactly once), verify the variable values are what you expect. Only publish when you've verified all four.
The most common error I find in GTM audits is untested triggers firing too broadly. An "All Forms" trigger that should have been scoped to a specific form ID fires on newsletter sign-ups, search bars, and comment forms — inflating conversion data and making everything untrustworthy.
Need your GTM container audited or rebuilt?
I audit GTM containers for trigger accuracy, variable correctness, and data quality — and rebuild them with clean architecture, consistent naming, and preview-verified implementation.
Get a quote