How to set up cross-domain tracking in ga4?

Member

by dortha , in category: SEO Tools , 6 months ago

How to set up cross-domain tracking in ga4?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer

by larry_orn , 6 months ago

@dortha 

To set up cross-domain tracking in Google Analytics 4 (GA4), you need to perform the following steps:

  1. Modify the Tracking Code: Insert the following code snippet immediately after the gtag('config', 'GA_MEASUREMENT_ID'); line in the GA4 tracking code on every page of your website, including both the source and destination domains:
1
2
3
4
5
gtag('config', 'GA_MEASUREMENT_ID', {
  'linker': {
    'domains': ['example.com', 'otherdomain.com']
  }
});


Replace GA_MEASUREMENT_ID with your GA4 Measurement ID.

  1. Set up Allowed Linker Domains: In your Google Analytics property settings, navigate to Data Streams, select your web data stream, and click on "Enable More Data Settings". Then, under "Enhanced Measurement", open the "Allowed Linker Domains" section and add the domains you want to track across as a comma-separated list.
  2. Verify the Referral Exclusion List: Confirm that the referral exclusion list in your GA4 property contains the domains you want to track across. Go to your Google Analytics property settings, click on "Tracking Info" and then "Referral Exclusion List". Add any additional domains you want to exclude. This step is optional, but it can help ensure accurate source attribution.
  3. Update Navigation Links: Update all navigation links between your source and destination domains to include the gtag.js linker parameter, data-ga4-linker="true". For example:
1
<a href="http://otherdomain.com/page" data-ga4-linker="true">Go to Other Domain</a>


  1. Testing: Test your implementation using the GA4 DebugView feature or by using Google Analytics Debugger browser extension. Ensure that the linker parameter appears on the destination URL when navigating between domains.


Once you have completed these steps, your cross-domain tracking should be set up in GA4, allowing you to track user behavior across multiple domains in a single GA4 property.