How to Set Up Cross-Domain Tracking in Google Analytics

Cross-domain tracking in Google Analytics allows you to track multiple websites as a single entity. This is especially useful for businesses with multiple domains that need to be tracked as a single property. Here’s a step-by-step guide to help you set up cross-domain tracking in Google Analytics:

Step-by-Step Guide to Set Up Cross-Domain Tracking

1. Identify the Domains

First, identify the domains you want to track. For example, if you have a main site at www.example.com and a blog at blog.example.com, you will need to set up tracking for both.

2. Update the Tracking Code

Update the Google Analytics tracking code on all the domains you want to track. Use the gtag.js or analytics.js code snippet and modify it to include the linker plugin.

For gtag.js:

gtag('config', 'UA-XXXXX-Y', {
  'linker': {
    'domains': ['example.com', 'blog.example.com']
  }
});

For analytics.js:

ga('create', 'UA-XXXXX-Y', 'auto');
ga('require', 'linker');
ga('linker:autoLink', ['example.com', 'blog.example.com']);
ga('send', 'pageview');
3. Set Up Referral Exclusions

Navigate to your Google Analytics Admin panel. Under the Property column, click on Tracking Info and then on Referral Exclusion List. Add your domains to this list to prevent them from being counted as referral traffic.

4. Test Your Setup

Use Google Tag Assistant or the Real-Time reports in Google Analytics to test your setup. Navigate between your domains and ensure that the sessions are being tracked correctly as a single user journey.

Example

Let’s say you own a primary website www.example.com and a secondary website shop.example.com. You want to track users who navigate between these two domains as a single session.

1. Identify the domains: www.example.com and shop.example.com.

2. Update the tracking code on both domains to include the linker plugin:

gtag('config', 'UA-XXXXX-Y', {
  'linker': {
    'domains': ['example.com', 'shop.example.com']
  }
});

3. Add both domains to the Referral Exclusion List in Google Analytics.

4. Test the setup by navigating between www.example.com and shop.example.com and check the Real-Time reports in Google Analytics to ensure proper tracking.

By following these steps, you can successfully set up cross-domain tracking in Google Analytics, allowing you to gain a comprehensive view of user interactions across multiple domains.


Did I miss anything? Add your comments below!