How do I configure cross-domain tracking in GA4?
Applies to: Google Analytics 4 (GA4)
Last updated: May 2025
Problem
You want to track users as they navigate across multiple domains (e.g., from example.com to checkout.examplepayments.com) without starting a new session or losing user attribution.
Solution
GA4 supports cross-domain tracking using automatic linking via the gtag.js or Google Tag Manager (GTM). You must configure it so GA4 can pass user identifiers between domains using URL parameters.
Step-by-Step Guide
Option 1: Configure via GA4 Admin (Web Stream Settings)
- Go to https://analytics.google.com
- Select your GA4 property
- Click Admin > Data Streams > Web
- Under Enhanced Measurement, click Configure tag settings
- Click Configure your domains under Cross-domain tracking
- Add all domains you want to track (e.g.,
example.com,examplepayments.com) - Click Save
This updates the domain list that GA4 uses to automatically link sessions across sites.
Option 2: Configure via gtag.js (Manual)
In your gtag.js implementation, modify the config as follows:
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX', {
'linker': {
'domains': ['example.com', 'examplepayments.com']
}
});
</script>
Option 3: Configure via Google Tag Manager (GTM)
- Open GTM and go to your GA4 Configuration Tag
- Click Fields to Set and add:
- Field Name:
linker - Value:
{domains: ['example.com','examplepayments.com']}
(Use a Custom JavaScript variable or set it directly in code if needed)
- Field Name:
- Alternatively, use the Auto Link Domains setting under tag configurations:
- Enable “Send to multiple domains”
- Add the domain list
- Save and publish your container
How It Works
GA4 appends a special query parameter (_gl=...) to URLs when users navigate across domains. This allows it to stitch sessions together across different sites without creating new users or sessions.
Notes
- Both domains must have GA4 tracking installed and configured
- Works only for links users click—not for redirects or iframe loads
- Don’t add subdomains like
shop.example.comunless you specifically use them with separate GA4 properties - Use GA4’s User Explorer or Explorations to verify that users remain unified across domains





