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:
- Separate checkout domain. Your main site is
example.combut checkout happens oncheckout.example-pay.com. Without linking, every purchase appears as a new session from a referral — your conversion path data is useless. - Third-party booking or form service. You use a tool like Calendly, Typeform, or a booking engine on its own domain. Users leave your site, complete an action, and return.
- Multiple brand domains. Your company runs
brand-a.comandbrand-b.comand you want unified analytics across both. - App and marketing site split. Marketing lives on
www.example.com, the app lives onapp.example.com(different subdomain tracked as a separate property).
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:
- Built-in admin UI. GA4 has a dedicated "Configure your domains" section under tag settings. No custom JavaScript needed.
- Automatic linker parameter. Once configured, GA4 automatically appends a
_glparameter to outbound links. This replaces the UA approach of decorating links with_gaand_gacparameters. - First-party cookies only. GA4 uses first-party cookies by default. The linker parameter passes the client ID between domains since cookies cannot be shared across different root domains.
- No separate "Cross Domain Tracking" plugin. The functionality is built into the GA4 tag itself. GTM handles it through the Configuration tag settings.
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.
- Open GA4 and go to Admin → Data Streams → select your web stream
- Click Configure tag settings (at the bottom of the stream details)
- Click Configure your domains
- Under "Include domains that match ANY of the following conditions," add each domain:
- Match type: Contains
- Domain:
example.com
- Add a new row for each additional domain:
shop.example-pay.com,app.example.io, etc. - 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.
- In GTM, open your Google Tag (formerly GA4 Configuration tag)
- Click Configuration Settings → expand Domains to link
- Add each domain you want to link:
example.com,shop.example-pay.com,app.example.io - 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:
- Client ID — the unique identifier for this browser/user, normally stored in the
_gacookie - Session ID — the current session identifier
- Timestamp — when the parameter was generated (it expires after 2 minutes)
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:
- The
_glparameter expires after 2 minutes. If a user copies a decorated URL and opens it later, the parameter is ignored and a new session starts. - GA4 decorates
<a>tags automatically. For JavaScript-based navigation (window.location.hrefchanges), you may need to manually decorate URLs using thegtagSetAPI. - Form submissions between domains require
decorate_forms: truein the linker configuration. Without it, POST-based navigations lose the client ID.
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 Type | Domain | What It Matches |
|---|---|---|
| Contains | example.com | example.com, www.example.com, shop.example.com |
| Contains | partner-checkout.com | partner-checkout.com, app.partner-checkout.com |
| Exactly matches | booking.thirdparty.io | Only 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:
- Main site + checkout:
example.com+secure-checkout.com— two "Contains" rules - Main site + app + docs:
example.com+app.example.io+docs.example.io— "Contains"example.com+ "Contains"example.io - Multi-brand:
brand-a.com+brand-b.com+brand-c.com— three separate rows - Regional domains:
example.com+example.co.uk+example.de— one row per country domain
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
- Open your main site in Chrome
- Right-click a link that points to your second domain
- Click Inspect and look at the
hrefattribute — it should remain unchanged in the HTML - Click the link normally
- 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
- In GTM, click Preview to launch Tag Assistant
- Enter your main domain URL
- Navigate to the second domain by clicking a link on the page
- In Tag Assistant, verify the GA4 tag fires on both domains
- Check that the client_id value is the same on both domains
Step 3: Confirm in GA4 DebugView
- Enable debug mode with the GA Debugger extension
- Navigate from domain A to domain B
- In GA4 DebugView, verify that events from both domains appear under the same device in the timeline
- Check that
session_startfires 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:
- Different GA4 properties per subdomain. If
shop.example.comuses a different Measurement ID thanwww.example.com, you are effectively running separate tracking — cookies will be set with different names and cross-domain linking won't help. Use the same Measurement ID across all subdomains instead. - Cookie domain mismatch. If your tag configuration explicitly sets the cookie domain to a specific subdomain (e.g.,
www.example.cominstead of.example.com), other subdomains cannot read the cookie. Check your GA4 tag's cookie configuration.
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.
- In GA4, go to Admin → Data Streams → select your web stream
- Click Configure tag settings
- Click List unwanted referrals
- Add each of your domains:
- Match type: Contains
- Domain:
example.com
- Add a row for each additional domain:
example-shop.net,checkout.partner.com - 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?
- Forgetting to exclude referrals. Cross-domain linking is set up, the linker parameter passes, but your own domains still appear as referral sources in reports. Always configure both linking and referral exclusion.
- Adding subdomains unnecessarily. Setting up cross-domain tracking for
www.example.comandblog.example.comwhen they share the same root domain. This adds unnecessary_glparameters to URLs and can cause issues with URL-based systems (caching, CDN rules, redirect logic). - Mismatched configuration across containers. Domain A's GTM container has cross-domain linking set up, but domain B's container does not accept incoming linker parameters. Both sides must be configured.
- URL parameter stripping. A redirect, CDN rule, or URL rewrite strips the
_glparameter before GA4 can read it. Check your server configuration, .htaccess rules, and CDN settings to ensure_glis preserved during redirects. - JavaScript-based navigation. Links generated dynamically via JavaScript (
window.open, SPA router navigations,window.location.href) may not be decorated automatically. You need to use thegtagSetAPI or manually append the linker parameter for these cases. - Form submissions without
decorate_forms. If users navigate between domains via form POST (e.g., a search form that submits to another domain), the linker parameter is not added unlessdecorate_forms: trueis set in the linker configuration. - Testing only in one direction. Cross-domain tracking must work both ways: A to B and B to A. Test navigation in both directions.
- Cookie consent blocking the linker. If your consent management platform blocks GA4 from running before consent, the linker parameter cannot be read on the destination domain. Ensure consent state is synchronized or at minimum that the linker parameter is processed even in the initial page load before full consent.
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:
- Open the extension on any of your domains
- Configure your GA4 tags and triggers visually — click elements, set event names, and create tags via the GTM API
- 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
- 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 HelperExternal Resources
- GA4: Set up cross-domain measurement
- GA4: List unwanted referrals
- GTM: Set up GA4 event tags
- Google Tag (gtag.js) API reference