MarketingChef

Free pantry › Guide 2 of 2

Free guide

How tracking works, and cross-domain tracking

  • Cost: $0, all free tools
  • Time: 20 to 40 minutes to read
  • Who it's for: every business, before any traffic

Chapter 1 installed the plumbing. This chapter is the two things you'll want when it gets interesting: a precise understanding of what Google Tag Manager is actually doing when it measures (so you can debug, extend, and trust it), and cross-domain tracking (how to keep one person whole when their journey crosses domains, and when you actually need it).

The plumbing chapter got you working. This chapter gets you understanding. With 25 years in the game, I'll skip the hand-waving and give you the mechanics exactly.

Part 1: The GTM model, precisely (what's actually happening)

Google Tag Manager is a container that runs tags on your site. Everything else is explained by four words. Learn these four and you can read any GTM setup in the world:

Tag, a snippet of code that executes and usually sends measurement info to a third party (a Google Analytics tag, a Google Ads conversion tag, a third-party pixel). Trigger, a condition that listens for events (page loads, clicks, form submissions) and fires any tag that references it when a match occurs. Variable, a named placeholder for a value that changes (product name, price, the URL, click text); variables define trigger filters and hand dynamic values into tags. Container, the collection of tags, triggers, variables, and config, deployed to your site with one snippet; it effectively replaces every hardcoded tag you'd otherwise paste into pages. (Verified: support.google.com/tagmanager/answer/6103657, /6102821, /6106899.)

The dataLayer, the messenger

The dataLayer is a JavaScript object (declared before Tag Manager loads: window.dataLayer = window.dataLayer || [];) that carries two things: events (dataLayer.push({'event':'purchase'})) and values (dataLayer.push({'price': 49})). GTM processes queued pushes first-in, first-out; before each message is processed as an event, every tag whose trigger matches fires. That ordering, push, then fire, is the entire reason custom events work. (Verified: developers.google.com/tag-platform/tag-manager/datalayer.)

The container snippet, and a 2026 change you'd otherwise trip over

As of 2026 the current snippet is a single <head> block (<script src="https://www.googletagmanager.com/gtm.js?id=GTM-…"></script>), placed as high as possible. It no longer includes a gtag config command. You configure initialization with the gtm init trigger instead. The older two-part snippet (script in head + <noscript> iframe in body for no-JS visitors) still works and needs no retag, but if you're writing setup instructions, write the current one. (Verified: support.google.com/tagmanager/answer/14847097, /17079602.)

Firing order & sequencing

A tag's Firing Priority is an integer (higher = earlier, default 0), but tags still fire asynchronously, so priority only orders the start. A quick translation: "asynchronously" means the browser does not wait for one tag to finish before it fires the next, and tags do not pause the page while they load. They start without blocking and can run at the same time. That is exactly why the completion order is not guaranteed, and why Priority only sets the order they start in. It is also good for speed, because a slow tag will not stall your page. For true dependencies use Tag Sequencing (a setup tag, then your tag, then a cleanup tag, chained on success/failure). (Verified: /2772421.)

Preview mode, where you do half your debugging

Preview runs the site as if your workspace draft were live, tied to Tag Assistant. The debug console (only in your browser, never shown to real visitors) shows each event and, per event: which tags fired and why, the resolved values of your variables, and the exact message on the dataLayer. That console is how you answer "did anything fire?" in 20 seconds. (Verified: /6107056.)

What Tag Assistant actually is (and where you get it)

You will see the name "Tag Assistant" in a few places in this book, so let's settle it once.

What it is. Tag Assistant is Google's free tool for debugging its tags: the ones from GA4, Google Ads, and Tag Manager. It watches your site and tells you which tags fired, whether they fired correctly, and what data they sent. When you hit Preview in Tag Manager, you are opening Tag Assistant.

Where to get it. Two ways, both free.

  • Browser extension: the Tag Assistant Chrome extension (search "Tag Assistant" in the Chrome Web Store). Google folded its older "Tag Assistant Legacy" and "Tag Assistant Companion" extensions into this single one.
  • Web, no extension needed: go to tagassistant.google.com. Tag Assistant now works without cookies and without an extension, so it works in any browser and asks you for nothing on your site.

How to use it. The simplest path: open your container in Tag Manager and click Preview. Tag Assistant opens in a new tab; enter your site URL and connect. Your site opens with a debug panel that lists every event and, for each one, the tags that fired, why, and the values on the dataLayer. For a recorded run you can keep, the browser extension's Troubleshoot button starts a session at tagassistant.google.com you can review later.

Server-side tagging, what, why, when

Server-side moves measurement tags out of the visitor's browser to your own server container (Google Cloud Run by default). Same tag/trigger/variable model, plus a new piece: the client, which receives raw requests, turns them into events, and routes them. Tags run in sandboxed JavaScript with explicit permissions.

Why bother? Fewer client tags → better page performance; your server owns the data until you route it → more control and security; and first-party serving (your own domain) → better data quality and less ad-blocker loss. When is it worth it? When you're running a lot of tags and want first-party data or better performance. That is the plumbing chapter's recommendation for serious teams. Maybe not day one; definitely on the roadmap. (Verified: developers.google.com/tag-platform/tag-manager/server-side/intro.)

2026 status you should know: Google tags are now fully capable GTM containers and the GTM UI was redesigned (a Settings section + an Advanced tab for Triggers/Variables/Templates). Nothing was removed; container optimization is optional. Details live in the verification memo. Also, Consent Mode v2 is the current standard with four signals (ad_storage, analytics_storage, ad_user_data, ad_personalization), GA4's diagnostics flag missing ones, so get those four right in the EEA/UK.

Part 2: Cross-domain tracking (keep one person one person)

What it is and when you need it

Cross-domain measurement keeps a visitor as one user / one session as they move across root domains, your main site and, say, a hosted checkout, a payment page on a different subdomain setup, or a separate funnel domain you don't control. Default behavior: domain A and domain B each keep their own cookies, so the same person looks like two users. Your funnel gets shredded and your conversions look split. (Verified: support.google.com/analytics/answer/10071811.)

You need it when a journey crosses root domains. And here's the subtle-but-real 2026 point from Google's docs: even with normal subdomains, GA4 recommends the setup when subdomains use different cookie domains, so you don't see self-referrals. The blanket rule: if a lead form, payment step, or funnel hub lives on a domain different from the tags' base domain, configure cross-domain.

How it works

The source domain decorates outbound links and forms with a linker parameter (_gl), e.g. https://checkout.site/?_gl=1~abcde5~. The destination domain, configured to accept incoming linkers, reads the _gl, restores the user/session IDs, and, same param, suppresses false referral noise between the linked domains. Every linked domain must share the same Google tag ID (G-) and the same data stream.

The exact setup (GA4 Admin)

  1. Confirm the same G- ID and same web data stream is on every domain you're linking.
  2. GA4 Admin → Data collection & modification → Data streams → Web → [your stream].
  3. Click Configure tag settings.
  4. Use Show all, then Configure your domains.
  5. Domains already using the same tag appear under Recommendations → click Add. To add manually: Add condition under Include domains that match the following conditions → choose a match type → enter the domain (example.com). Add each domain; conditions use OR logic. Up to 100 conditions.
  6. Save. Then navigate a configured link on your site and confirm the destination URL carries _gl. That's your verification.

Referral exclusion (a separate control; don't conflate it)

"Unwanted referrals" (referral exclusion) lives in a different place: Data streams → [stream] → Configure tag settings → Show all → List unwanted referrals (up to 50), and it's mainly for third-party payment processors / gateways (Google's own canonical example). Because GA4 automatically prevents self-referrals, your own cross-domain domains generally do not also need referral exclusion. So: cross-domain for your funnel domains; unwanted-referrals for third-party gateways. Don't blur them. (Verified: /10327750.)

GTM side-note: GA4 cross-domain is configured in Analytics Admin, not GTM. For non-Analytics products (Ads/Floodlight) the GTM answer is a Conversion Linker tag with enable linking across domains + Auto Link Domains, fired on All Pages. And if you're pure gtag.js, set the linker before config: gtag('set', 'linker', {'domains':[…]}).

Cross-domain traps (the ones that silently break it)

  • JS-triggered navigation (a click handler redirects instead of a normal link). The linker never gets applied.
  • A competing script calls Event.stopPropagation().
  • A redirect strips the _gl query.
  • All three fail quietly. The fix is the same check: after navigating a configured link, the destination URL must contain _gl. If it doesn't, one of these three just happened.

✅ Tested and working. Verify cross-domain end to end. If you have a separate domain in play, run a real journey: start a session on your main site, click the configured link to the other domain, and confirm the destination URL carries _gl. Then in GA4, confirm the session shows as one user across both domains and does not split into two sessions or a fake self-referral. If _gl is missing, revisit the traps above (JavaScript navigation, Event.stopPropagation(), redirects) and confirm the same tag ID is on both domains.

Wiring to the recipes

This chapter is the "understand the pipes" companion to R003 (GA4) / R004 (Tag Manager) and the plumbing chapter. When a later recipe says "make sure your funnel is tracked across this step," that's the how (cross-domain). When something doesn't fire, this is the why and the debug path (Preview console). The glossary defines every term used here.

What "done" looks like

  • You can explain, not guess, what tag, trigger, variable, and dataLayer each do.
  • You can use Preview to see why a tag fired or didn't, in under a minute.
  • A journey that crosses a root domain is one continuous user/session in GA4 (verified via _gl in the destination URL), with third-party gateways handled by unwanted-referrals separately.
  • You know exactly when cross-domain is needed and when it isn't (and you don't set it up in the wrong place).

Sources: what we verified and where it lives (as of 2026-11)

  • GTM components/intro/variables: support.google.com/tagmanager/answer/6103657 · /6102821 · /6106899 · /7683056 · /7182738
  • dataLayer: developers.google.com/tag-platform/tag-manager/datalayer
  • Install web container (2026 snippet): support.google.com/tagmanager/answer/14847097 · /17079602
  • Firing priority / sequencing: /2772421 · Preview/debug: /6107056 · Zones: /7647043
  • Server-side: developers.google.com/tag-platform/tag-manager/server-side/intro
  • Cross-domain GA4: support.google.com/analytics/answer/10071811 · unwanted referrals: /10327750 · Conversion Linker: /7549390 · gtag cross-domain: developers.google.com/tag-platform/devguides/cross-domain
  • Consent Mode v2: support.google.com/tagmanager/answer/10000067 · /14522438