[Solved] How to Set Up Cross-Domain Tracking in GA4 with Multiple GTM Containers for Separate Domains
Cross-domain tracking is essential when you have multiple domains and want to track users seamlessly across them in Google Analytics 4 (GA4). However, when each domain has a separate Google Tag Manager (GTM) container, setup can get tricky.
In this guide, we’ll walk you through a step-by-step approach to setting up cross-domain tracking in GA4 while managing different GTM containers for each domain.
Why is Cross-Domain Tracking Important?
By default, GA4 treats each domain as a separate entity. Without proper cross-domain tracking:
– Sessions break when users navigate between your domains.
– Users are counted as new visitors when they switch domains.
– Attribution data (UTMs, referral sources) gets lost.
By enabling cross-domain tracking, GA4 will correctly attribute traffic and retain user session continuity across your domains.
Step 1: Use the Same GA4 Measurement ID in All GTM Containers
Each of your domains should send data to the same GA4 property.
1. Go to GA4 Admin → Data Streams → Click on Your Web Data Stream.
2. Copy the Measurement ID (format: `G-XXXXXXXXXX`).
3. In each GTM container:
– Create a Google Tag.
– Paste the same Measurement ID.
– Set the trigger to All Pages.
– Save and Publish.
Now all domains are sending data to the same GA4 property.
Step 2: Enable Cross-Domain Tracking in GA4
This ensures GA4 recognizes visits across your domains as part of the same session.
1. Go to GA4 Admin → Data Streams → Click on Your Web Data Stream.
2. Click Configure Tag Settings → Configure Your Domains.
3. Add all domains that need tracking:
– Example: `domainA.com`, `domainB.com`, ‘domainC.com’
4. Click Save.
GA4 will now track user navigation across these domains as a single session.
Step 3: Prevent Self-Referrals in GA4
Without this step, GA4 may incorrectly treat your own domains as referral traffic.
1. Go to GA4 Admin → Data Streams → Click Your Web Data Stream.
2. Under Tag Settings, click List Unwanted Referrals.
3. Add all your domains to the list.
4. Click Save.
This prevents your own websites from showing up as referral sources.
Understand URL Parameters for Cross-Domain Tracking
GA4 uses link decoration to pass client identifiers (like `gclid` or `ga_session_id`) between domains. When a user clicks a link from one domain to another, GA4 automatically appends URL parameters:
– `_gl`: Contains encrypted information about the session and client ID.
– `gclid`: Google Ads click identifier.
– `ga_session_id`: The session identifier.
These parameters allow GA4 to stitch sessions across domains without manual setup.
Optional: Preserve UTM Parameters Automatically
If a user lands on `domainA.com` with UTM parameters and then clicks to `domainB.com`, GA4 might lose the original UTMs. To avoid this:
1. In each GTM container, create URL Variables:
– Go to Variables → New → URL Variable.
– Set Component Type: Query Parameter.
– Create variables for:
– `utm_source`
– `utm_medium`
– `utm_campaign`
2. Modify the Google Tag to capture UTMs:
– Open the Google Tag in GTM.
– Click Event Parameters → Add Row for each UTM.
– Map each parameter to the respective GTM variable.
– Save and Publish.
This step is optional, as GA4 will automatically attribute the original UTM parameters to future events within the same session.
Step 5: Test Your Cross-Domain Tracking
1. Use GTM Preview Mode in All Containers
– Open GTM → Click Preview for each container.
– Test your setup by navigating between domains.
– Check if your Google Tag fires correctly in all GTM containers.
2. Check GA4 DebugView
– Go to GA4 Admin → DebugView.
– Click through links between your domains.
– Ensure GA4 doesn’t start a new session when switching domains.
Conclusion
Setting up cross-domain tracking with separate GTM containers for each domain requires careful configuration in both GA4 and GTM. By following these steps, you ensure that users are tracked accurately, attribution is preserved, and analytics reports remain consistent.
🚀 Need help troubleshooting? Drop your questions in the comments!