Back to Blog
Analytics
Jan 20, 2025
Ludde

GA4 Cross-Domain Tracking: Setup, Testing, and Common Pitfalls

Self-referrals killing your attribution? Here's the definitive guide to cross-domain tracking in GA4.

GA4 Cross-Domain Tracking: Setup, Testing, and Common Pitfalls

Cross-domain tracking in GA4 solves a specific problem: when your user journey spans multiple domains (e.g., shop.example.com to checkout.example.com), GA4 treats each domain as a separate session by default. This fragments the user journey and breaks attribution — the referral from your own domain appears as a new traffic source, making it impossible to understand how users convert across your properties.

GA4 handles cross-domain tracking differently from Universal Analytics, and many teams either haven't configured it correctly or have over-configured it for domains that don't need it. This guide explains when you actually need cross-domain tracking, how to set it up properly, and the subtle issues that can corrupt your data if you get it wrong.

When Do You Actually Need Cross-Domain Tracking?

Cross-domain tracking is needed when all three of these conditions are true:

  1. Users navigate between different domains (not subdomains) as part of the same journey.
  2. Both domains are tracked by the same GA4 property (same Measurement ID).
  3. You want to track the user as a single session across both domains.

Common scenarios that require cross-domain tracking:

  • Main site (example.com) → Third-party checkout (shop.shopify.com/example)
  • Marketing site (example.com) → App/dashboard (app.example.io)
  • Regional sites (example.co.uk) → Global checkout (store.example.com)

Important: Subdomains (e.g., blog.example.com and shop.example.com) do not require cross-domain tracking. GA4 uses first-party cookies scoped to the root domain, so subdomains are automatically tracked in the same session. Setting up cross-domain tracking for subdomains is a common mistake that adds unnecessary complexity.

GTM workspace overview showing container settings and tags list for cross-domain configuration

How GA4 Cross-Domain Tracking Works

Unlike Universal Analytics, which required manual linker configuration in GTM, GA4 handles cross-domain tracking through the Admin → Data Streams → Configure Tag Settings → Configure Your Domains interface. Here's what happens under the hood:

  1. When a user clicks a link from Domain A to Domain B, GA4 appends a _gl parameter to the URL containing the client ID and session information.
  2. When Domain B's GA4 tag loads, it reads the _gl parameter and uses the client ID from Domain A instead of generating a new one.
  3. Both page views are attributed to the same user and same session, preserving the conversion path.

This linker parameter approach means the user's identity is passed through the URL itself — no server-side communication is needed. However, it also means the _gl parameter must survive the redirect. URL shorteners, certain redirect services, and some WAFs (Web Application Firewalls) strip unknown query parameters, breaking the chain.

Setup Steps

Step 1: Configure Domains in GA4 Admin

  1. Go to Admin → Data Streams and select your web stream.
  2. Click Configure Tag Settings (at the bottom of the stream details).
  3. Click Configure Your Domains.
  4. Add each domain that participates in cross-domain tracking. Use the "contains" match type for simplicity (e.g., example.com will match shop.example.com, blog.example.com, etc.).
  5. Click Save.

Step 2: Verify Both Domains Have the Same Measurement ID

Both domains must be sending data to the same GA4 property (same Measurement ID). Check your GTM containers or gtag.js implementations on both domains to ensure the Measurement ID matches. A common mistake is having Domain B use a different GA4 property — cross-domain tracking won't work across different properties.

Step 3: Update Referral Exclusions

By default, when a user navigates from Domain A to Domain B, Domain A appears as a referral source for Domain B. This creates self-referrals in your traffic source reports. To fix this:

  1. Go to Admin → Data Streams → Configure Tag Settings → List Unwanted Referrals.
  2. Add all your domains to the unwanted referral list. This tells GA4 not to create new sessions when traffic comes from these domains.

Without this step, you'll see your own domains appearing as top referral sources in your acquisition reports — a clear sign that cross-domain tracking isn't fully configured.

Testing Your Implementation

Cross-domain tracking issues are silent — you won't get error messages. Use these methods to verify:

  1. Check the URL: Navigate from Domain A to Domain B and inspect the URL. You should see a _gl parameter appended. If it's missing, the linker configuration isn't working.
  2. Compare client IDs: Open Chrome DevTools on both domains and check the GA4 cookie (_ga) value. The client ID should be identical on both domains after cross-domain navigation.
  3. GA4 Realtime Report: Navigate between domains and check the Realtime report. You should see a single active user, not two.
  4. Check referral reports: In GA4, go to Traffic Acquisition and check if your own domains appear as referral sources. If they do, your unwanted referral list isn't configured correctly.
  5. GA4 DebugView: Enable debug mode on both domains and verify that the same client ID appears for events on both domains.

Common Problems and Fixes

  • Self-referrals in reports: You forgot to add domains to the unwanted referral list. Go to Admin → Data Streams → Configure Tag Settings → List Unwanted Referrals and add all your domains.
  • The _gl parameter is stripped: Some URL redirect services, CDNs, or JavaScript routers strip query parameters during navigation. Test the full redirect chain to identify where parameters are being lost.
  • Different Measurement IDs: Both domains must use the same GA4 Measurement ID. A common mistake with acquired companies or legacy properties is having different IDs on different domains.
  • Form submissions vs. link clicks: GA4's automatic cross-domain linker only decorates <a> tag clicks by default. If users navigate between domains via form submissions, you may need custom JavaScript to append the _gl parameter to the form action URL.
  • iFrames: Cross-domain tracking through iFrames requires additional configuration and is generally more fragile. Consider whether the iframe content truly needs to be part of the same session.

When NOT to Use Cross-Domain Tracking

  • Subdomains: As mentioned above, subdomains of the same root domain share cookies automatically. Adding them to cross-domain configuration is unnecessary and can cause issues.
  • Different businesses: If two domains represent completely different businesses with separate user bases, tracking them as one property creates noisy, meaningless data. Use separate GA4 properties instead.
  • Third-party sites you don't control: If users navigate to a payment gateway or external service where you can't install your GA4 tag, cross-domain tracking won't work. Instead, add that domain to your unwanted referral list to prevent session fragmentation on return.

Automatic Detection

NiceLookingData detects self-referrals in your GA4 data, identifies missing unwanted referral exclusions, and flags cross-domain configuration gaps that cause session fragmentation. We also alert you to subdomains that have been unnecessarily added to cross-domain configuration.

Key Takeaways

  • Cross-domain tracking is only needed for different root domains, not subdomains — GA4 handles subdomains automatically.
  • Configure domains in GA4 Admin (Data Streams → Configure Tag Settings → Configure Your Domains).
  • Always update the unwanted referral list to prevent self-referrals from fragmenting your session data.
  • Test by checking the _gl parameter in URLs and comparing client IDs on both domains.
  • Form submissions and redirects can break the linker parameter chain — test the complete user journey, not just direct link clicks.
Thanks for reading!