Blog

← All articles

How to Set Up Cross-Domain Tracking in Google Tag Manager

TL;DR: Cross-domain tracking in GA4 lets you follow a single user session across multiple domains. Configure it in GA4 Admin under Data Streams → Configure tag settings → Configure your domains, then add all domains to the list. In GTM, your GA4 Configuration tag handles the linker parameter automatically once GA4 admin is set up. Exclude your own domains from referral traffic, and test with Tag Assistant to confirm the _gl parameter passes between domains.

When your business spans multiple domains — a marketing site on example.com, a shop on shop.example.com, and a checkout on pay.example.com — Google Analytics treats each domain as a separate traffic source by default. A user who starts on your blog and finishes a purchase on your checkout domain appears as two separate sessions with the second one attributed to a referral from your own site. Cross-domain tracking solves this by linking sessions across domains into a single user journey.

This guide walks through the full setup: GA4 admin configuration, GTM tag settings, the linker parameter, multi-domain setups, subdomain handling, referral exclusions, testing, and the mistakes that break cross-domain tracking most often.

What is cross-domain tracking and when do I need it?

Cross-domain tracking maintains a single user session as visitors move between different domains that you own. Without it, each domain boundary creates a new session in GA4, inflating your session counts and breaking attribution.

You need cross-domain tracking when:

You do not need cross-domain tracking for subdomains under the same root domain if they share the same GA4 measurement ID and the same first-party cookie domain. GA4 handles subdomains automatically in most cases. More on this distinction later.

How does GA4 handle cross-domain tracking differently from Universal Analytics?

In Universal Analytics, cross-domain tracking required manual linker plugin configuration, allowLinker: true, autoLink domains, and careful cookie domain settings. It was fragile and error-prone.

GA4 simplifies this significantly:

The core challenge remains the same: browsers restrict cookies to the domain that set them. When a user moves from site-a.com to site-b.com, site-b.com cannot read the GA4 cookie set by site-a.com. The linker parameter bridges this gap by passing the client ID through the URL.

How do I configure cross-domain tracking in GA4 admin?

This is the primary method and works whether you use GTM or the gtag.js snippet directly.

  1. Open GA4 and go to AdminData Streams → select your web stream
  2. Click Configure tag settings (at the bottom of the stream details)
  3. Click Configure your domains
  4. Under "Include domains that match ANY of the following conditions," add each domain:
    • Match type: Contains
    • Domain: example.com
  5. Add a new row for each additional domain: shop.example-pay.com, app.example.io, etc.
  6. Click Save

Once saved, GA4 automatically decorates links pointing to the listed domains with the _gl linker parameter. The receiving domain reads this parameter, extracts the client ID, and continues the same session.

Important: enter just the domain name (e.g., example.com), not the full URL. The "Contains" match type means example.com will also match shop.example.com and blog.example.com.

How do I set up cross-domain tracking in GTM?

If you manage GA4 through Google Tag Manager, the GA4 admin configuration above still applies — GA4's tag settings work regardless of the implementation method. However, you can also configure cross-domain linking directly in your GTM tag.

  1. In GTM, open your Google Tag (formerly GA4 Configuration tag)
  2. Click Configuration Settings → expand Domains to link
  3. Add each domain you want to link: example.com, shop.example-pay.com, app.example.io
  4. Save the tag

Alternatively, use the Fields to Set section:

Field Name: linker
Value: {"domains": ["example.com", "shop.example-pay.com"], "accept_incoming": true}

The first approach (Domains to link) is simpler and recommended for most setups. The Fields to Set approach gives you more control over linker behavior, such as disabling accept_incoming on specific domains or adding decorate_forms: true for form-based navigation between domains.

One container or multiple? If all domains share the same GTM container, configure cross-domain linking once in that container. If each domain has its own GTM container, configure the linker settings in every container — each domain must both send and accept the linker parameter.

How does the linker parameter work?

When a user clicks a link from site-a.com to site-b.com, GA4 appends a _gl parameter to the URL:

https://site-b.com/page?_gl=1*1abc2de*_ga*MTIzNDU2Nzg5MC4xNjk...

This parameter contains:

When site-b.com loads and GA4 initializes, it reads the _gl parameter, extracts the client ID, and sets its own first-party _ga cookie with the same client ID. The session continues seamlessly.

Key technical details:

How do I add multiple domains to cross-domain configuration?

Adding multiple domains is straightforward but requires attention to match patterns. In GA4 Admin → Configure your domains, add one row per domain:

Match TypeDomainWhat It Matches
Containsexample.comexample.com, www.example.com, shop.example.com
Containspartner-checkout.compartner-checkout.com, app.partner-checkout.com
Exactly matchesbooking.thirdparty.ioOnly booking.thirdparty.io

Use Contains for domains you fully control — it covers subdomains automatically. Use Exactly matches for third-party domains where you only want to link one specific subdomain, not the entire domain tree.

Common multi-domain scenarios:

There is no hard limit on the number of domains you can add, but keep the list focused on domains where users actually navigate during a session. Adding domains that users never cross to is harmless but adds unnecessary link decoration.

How do I test cross-domain tracking?

Testing is critical. A misconfigured cross-domain setup silently inflates session counts and breaks attribution for weeks before anyone notices.

Step 1: Check link decoration

  1. Open your main site in Chrome
  2. Right-click a link that points to your second domain
  3. Click Inspect and look at the href attribute — it should remain unchanged in the HTML
  4. Click the link normally
  5. Check the browser URL bar on the destination page — you should see ?_gl=1*... appended to the URL

Step 2: Verify with GTM Tag Assistant

  1. In GTM, click Preview to launch Tag Assistant
  2. Enter your main domain URL
  3. Navigate to the second domain by clicking a link on the page
  4. In Tag Assistant, verify the GA4 tag fires on both domains
  5. Check that the client_id value is the same on both domains

Step 3: Confirm in GA4 DebugView

  1. Enable debug mode with the GA Debugger extension
  2. Navigate from domain A to domain B
  3. In GA4 DebugView, verify that events from both domains appear under the same device in the timeline
  4. Check that session_start fires only once (on domain A), not again on domain B

Step 4: Check GA4 Realtime report

After publishing, navigate between your domains and check the GA4 Realtime report. You should see a single active user, not two. If you see two active users on the same device, cross-domain linking is not working.

How do I handle subdomains vs separate domains?

This is the most misunderstood part of cross-domain tracking. The rules are different for subdomains and separate root domains.

Subdomains (same root domain)

Examples: www.example.com, shop.example.com, blog.example.com

GA4 handles subdomains automatically. The _ga cookie is set on the root domain (.example.com) by default, so all subdomains can read it. You do not need cross-domain tracking for subdomains under the same root domain.

However, there are exceptions:

Separate root domains

Examples: example.com and example-shop.net

These always require cross-domain tracking. Cookies set on example.com are invisible to example-shop.net. The linker parameter is the only way to pass the client ID between them.

Public suffix edge cases

Domains like example.co.uk and example.com.au have multi-part public suffixes. GA4 handles these correctly — the cookie is set on .example.co.uk, not on .co.uk. Subdomains under example.co.uk share cookies normally. But example.co.uk and example.com are separate root domains and require cross-domain linking.

How do I exclude referral traffic from my own domains?

Even with cross-domain tracking configured, GA4 may still count traffic between your domains as referral unless you exclude your own domains from the referral list. This shows up in reports as source / medium = example.com / referral instead of the original traffic source.

  1. In GA4, go to AdminData Streams → select your web stream
  2. Click Configure tag settings
  3. Click List unwanted referrals
  4. Add each of your domains:
    • Match type: Contains
    • Domain: example.com
  5. Add a row for each additional domain: example-shop.net, checkout.partner.com
  6. Click Save

Why this is a separate step: configuring cross-domain linking (the linker parameter) ensures the client ID passes between domains. Excluding referrals ensures GA4 does not attribute the second page view to a referral source. You need both. Linking without referral exclusion gives you correct session counts but wrong attribution. Referral exclusion without linking gives you correct attribution but inflated session counts.

A common mistake is adding third-party payment providers (PayPal, Stripe) to the referral exclusion list without also setting up cross-domain linking. This hides the referral but does not actually link the sessions — you lose visibility into where users come from and the session still breaks.

What are common cross-domain tracking mistakes?

Is there a faster way to set up cross-domain tracking?

The standard setup requires navigating GA4 Admin, GTM tag settings, referral exclusion lists, and testing across multiple domains manually. It is easy to miss a step, especially when dealing with three or more domains.

GTM Event Helper streamlines the process:

  1. Open the extension on any of your domains
  2. Configure your GA4 tags and triggers visually — click elements, set event names, and create tags via the GTM API
  3. The AI Agent analyzes your page structure and suggests the correct tracking setup, including cross-domain scenarios when it detects links to external domains you own
  4. Tags and triggers are created consistently across your GTM workspace, reducing the risk of mismatched configurations between domains

Instead of switching between GA4 Admin, GTM, and your site, you handle the tag and trigger creation from a single interface directly on the page.

Simplify your GTM setup across all domains.

Install GTM Event Helper

External Resources

Related Articles

← All articles · Home · Privacy Policy · Contact