About Tracking

Ad Platform Tracking

Meta Pixel + CAPI TikTok CAPI LinkedIn CAPI Snapchat CAPI Pinterest CAPI Quora Pixel Bing + UET Tag

Google Ecosystem

Google Ads Tracking GA4 Setup & Audit Google Tag Manager

Advanced Solutions

Server-Side Tracking Looker Studio Offline Conversion
Case Studies Blog Free Checklist Book Free Audit →

Google Tag Manager has three building blocks: tags (what to do), triggers (when to do it), and variables (what data to use). If you understand tags but find variables and triggers confusing, this guide clarifies how they work and how they relate to each other in the context of Shopify ecommerce tracking.

What GTM Variables Are

Variables are named references to dynamic values that change based on the current page, user action, or dataLayer content. They are the mechanism GTM uses to pass specific data into tags.

When you set up a GA4 Purchase event tag, you need to tell GTM where to find the purchase value, the transaction ID, and the items array. You do this by creating variables that read those values from the page.

The Main Types of GTM Variables

Built-in variables (always available):

DataLayer Variables (most important for ecommerce):

Read values that Shopify or your GTM tags push to window.dataLayer. For example, if the dataLayer contains {'ecommerce': {'value': 149.99}}, you create a DataLayer Variable with the path “ecommerce.value” to read 149.99 into your GA4 tag.

JavaScript Variables:

Execute a small JavaScript function and use the return value. Useful for reading data that exists in the page’s global JavaScript scope but is not in the dataLayer.

Constant Variables:

Store a fixed value (like your GA4 Measurement ID) that can be referenced across multiple tags. Change the value once in the variable, and all tags update automatically.

Lookup Tables:

Map one value to another. For example, map URL path patterns to page categories: “/products/” → “Product Page”, “/collections/” → “Collection Page.”

What GTM Triggers Are

Triggers are conditions that control when a tag fires. Every tag in GTM must have at least one trigger. The trigger defines what event or state must occur for the tag to activate.

The Main Types of GTM Triggers

Page View triggers:

Click triggers:

Leave a Reply

Your email address will not be published. Required fields are marked *