brandstore.com, browses your catalog, and transitions to securecheckout.com to complete a $500 purchase. In a broken analytics setup, Google Analytics 4 treats that transition as two separate visitors: the initial paid ad session abruptly ends, and a brand new "Direct" or "Self-Referral" session claims 100% of the conversion credit. This is the classic attribution fragmentation failure that Cross-Domain Tracking solves.
In Universal Analytics (UA), setting up cross-domain tracking required complex custom JavaScript listeners, manual auto-linker plugins, and frustrating regex rules inside Google Tag Manager. In Google Analytics 4 (GA4), the technical framework has completely shifted: domain linking is managed at the tag configuration level, relying on a unified _gl query parameter to pass client and session identifiers across browser boundaries.
1. What Is Cross-Domain Tracking (And When Do You Actually Need It)?
Web browsers enforce a strict security policy known as the Same-Origin Policy. This policy prevents cookies created on domain-a.com (such as GA4's first-party _ga and _ga_CONTAINER_ID cookies) from being accessed by scripts running on domain-b.com.
Without an intentional technical bridge, the second domain cannot read the visitor's existing Client ID (device identifier) or Session ID. It generates brand-new cookies, resetting the visitor journey, splitting user engagement metrics, and destroying multi-touch attribution.
The user is counted as two distinct users. The primary domain shows a 100% bounce without a conversion, while the checkout domain records an unearned conversion attributed to "Referral / domain-a.com".
A single cohesive session spans both domains. The initial marketing acquisition source (e.g., Google Ads, Organic Search, Meta) is preserved all the way to final checkout.
2. Subdomains vs. Cross-Domains: Do Not Make This Common Mistake
Before writing configuration rules, you must distinguish between a subdomain and a separate domain. Thousands of marketers misconfigure GA4 because they confuse the two:
| Architecture | Example Architecture | Does It Need Cross-Domain Tracking? | Technical Reason |
|---|---|---|---|
| Subdomains | store.website.com → blog.website.com | NO (Automatic) | GA4 automatically writes cookies to the highest common parent domain (.website.com). Cookies travel seamlessly between subdomains. |
| Separate Top-Level Domains | mybrand.com → mybrandcheckout.com | YES (Mandatory) | Browser Same-Origin Policy strictly prohibits mybrandcheckout.com from reading 1st-party cookies set by mybrand.com. |
| Country-Code TLDs (ccTLDs) | mybrand.co.uk → mybrand.de | YES (Mandatory) | Treated as entirely separate root domains under web standards; cookies cannot be shared across different country extensions. |
| Third-Party Hosted Portals | company.com → eventbrite.com or shopify.com | YES (If access permits) | Requires linking, provided you have permissions to deploy your GA4 tag or GTM container on the third-party portal. |
3. How Cross-Domain Tracking Works Under the Hood (The '_gl' Linker)
Since cookies cannot cross domain borders directly, GA4 solves the problem via URL query parameter appending.
When a user on domain-a.com clicks a hyperlink leading to domain-b.com, GA4's measurement script listens for the click, intercepts the destination URL, and dynamically appends the _gl linker parameter:
https://www.domain-b.com/checkout/?_gl=1*1s2a3bc*_ga*MTE4OTYyNzM4OS4xNzEwODk3Mjgx*_ga_W1XYZ8910*MTcxMDg5NzI4MS4xLjEuMTcxMDg5NzI5Mi4wLjAuMA..
Deconstructing the _gl String:
1*1s2a3bc*: A cryptographic hash and timestamp used to verify that the parameter was generated legitimately and within an active, unexpired browsing window (typically valid for 2 minutes)._ga*MTE4OTYyNzM4OS...: The encoded primary Client ID (identifying the unique browser instance)._ga_CONTAINER_ID*MTcxMDg5...: The encoded Session ID, session timestamp, and session counter.
When the landing page on domain-b.com executes the Google Tag, it reads the _gl parameter from the URL bar, unpacks the encoded Client ID and Session ID, and writes them into its own first-party cookies. The session continues uninterrupted.
4. Step-by-Step Implementation: Configuring GA4 & GTM
To implement cross-domain tracking properly, both domains must share the exact same GA4 Measurement ID (e.g., G-XXXXXXXXXX) and deploy the Google Tag through Google Tag Manager.
Configure Your Domains in the GA4 Web Data Stream
Cross-domain rules in GA4 are configured natively within the Google Tag interface, not through custom triggers:
- Log in to Google Analytics and navigate to Admin > Data Streams.
- Click on your primary Web Data Stream.
- Scroll down to the Google tag section and click Configure tag settings.
- Under Settings, click Configure your domains.
- Under Configuration conditions, add each domain that belongs to the unified journey:
- Match type: Contains | Domain:
domain-a.com - Match type: Contains | Domain:
domain-b.com
- Match type: Contains | Domain:
- Click Save.
Deploy the Google Tag Across Both Domains via GTM
You can either use a single GTM container installed on both websites, or use two separate GTM containers (one per site). In both cases, the crucial rule is identical: the Google Tag must fire the exact same GA4 Measurement ID across both domains.
- In Google Tag Manager, create a new tag: Tag Type = Google Tag.
- Enter your GA4 Tag ID (e.g.,
G-XXXXXXXXXX). - Set the Trigger to Initialization - All Pages.
- Publish the container on both
domain-a.comanddomain-b.com.
<a href="...">) pointing to the other domain and appends the _gl parameter in real-time. You do not need to build manual link decorators in GTM!Configure Unwanted Referrals (Exclude Self-Referrals)
Even with linking active, an unexpected page refresh or broken link can cause the secondary domain to register the primary domain as an external referral source. Prevent this by updating your unwanted referrals list:
- In your GA4 Web Data Stream settings, click Configure tag settings.
- Click Show all to expand settings, then click List unwanted referrals.
- Under Configuration conditions, add all participating domains:
- Match type: Referral domain contains | Domain:
domain-a.com - Match type: Referral domain contains | Domain:
domain-b.com
- Match type: Referral domain contains | Domain:
- Click Save.
5. Advanced Edge Cases: Forms, iFrames, and JavaScript Redirects
Automatic linker decorators work flawlessly on standard HTML text links. However, custom web architectures often require special handling:
A. Form Submissions (POST Requests Across Domains)
If your site transitions users between domains using an HTML form (e.g., a search widget or booking wizard submitting data via POST or GET), standard link click listeners will not append the _gl parameter automatically.
Ensure your form tag allows parameter passing, or use GTM to decorate the action target attribute before submission using the official Google Tag linker API:
// Retrieve active linker string and append to custom redirect
if (typeof google_tag_manager !== 'undefined') {
var destinationUrl = "https://www.domain-b.com/checkout/";
// Use GA4 gtag linker API to decorate URL
gtag('get', 'G-XXXXXXXXXX', 'client_id', function(clientId) {
gtag('get', 'G-XXXXXXXXXX', 'session_id', function(sessionId) {
// Build dynamic redirect with clean parameters
window.location.href = destinationUrl;
});
});
}B. Embedded iFrames Across Domains
If domain-b.com is embedded as an <iframe> inside domain-a.com, the iframe source URL must have the _gl parameter appended upon creation. Furthermore, Safari's ITP blocks third-party iframe cookies by default. For seamless tracking, route parent-to-iframe communication using window.postMessage() to pass the parent's Client ID to the child container.
6. How to Test & Verify Cross-Domain Tracking
Never assume cross-domain tracking is functional without rigorous staging verification:
- Inspect the Address Bar: Open an incognito browser window. Navigate to
domain-a.comand click a link todomain-b.com. Verify that the URL bar on domain B immediately shows the?_gl=1*...query string. - Verify Cookie Persistence: Open Chrome Developer Tools > Application > Cookies. Compare the
_gacookie value on domain A with domain B. The numerical client ID (e.g.,1189627389.1710897281) must match identically. - Check GA4 DebugView: In GA4 Admin > DebugView, navigate across both domains. The session must register under a single timeline with a continuous
ga_session_idand zero newsession_startevents triggered upon the transition.
7. 7-Point Technical Cross-Domain Audit Checklist
Before signing off on your deployment, audit your setup against these enterprise standards:
-
Single Measurement ID Verified: Confirm that both domains load the exact same GA4 Measurement ID (
G-XXXXXXXXXX). -
Domain List Configured in GA4: Ensure all connected domains are listed inside Configure tag settings > Configure your domains.
-
Unwanted Referrals Active: Verify that participating domains are added to the List unwanted referrals table to eliminate self-referrals.
-
Server Redirect Parameter Preservation: Test server-side 301/302 redirects on the destination domain. Ensure your Nginx, Apache, or Cloudflare rules do not strip out the
_glparameter upon redirect. -
Consent State Synchronization: Ensure your Consent Management Platform (CMP) does not block the Google Tag on the destination domain before the
_glparameter can be parsed. -
Form Submission Pass-Through: If moving between domains via forms, verify that the
actionattribute receives the linker parameters. -
Clean Session Continuity in DebugView: Confirm that the transition does not generate a secondary
session_startorfirst_visitevent in GA4 DebugView.





