Tracking website performance across multiple domains in Google Analytics involves setting up cross-domain tracking. This is essential when you have multiple related domains and want to track user behavior seamlessly across them. Here’s a step-by-step guide on how to achieve this:
Step 1: Understand Cross-Domain Tracking
Cross-domain tracking allows Google Analytics to track sessions on two related sites (e.g., example.com and blog.example.com) as a single session. This is achieved by sharing the Google Analytics cookies across domains.
Step 2: Prerequisites
- Google Analytics Setup: Ensure you have Google Analytics set up for all domains you want to track.
- Universal Analytics: This guide assumes you are using Universal Analytics (analytics.js).
Step 3: Modify Tracking Code on All Domains
You’ll need to modify the tracking code on each domain to enable cross-domain tracking.
- Identify Tracking Code: Locate your Google Analytics tracking code (
analytics.js
). - Update Tracking Code:
- Add the
analytics.js
tracking code snippet to each page of your website just before the closing</head>
tag. - Customize the snippet for each domain by replacing
'UA-XXXXX-Y'
with your property ID.
Example:
html<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXX-Y"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXX-Y');
</script>
- Add the
- Include Cross-Domain Tracking Code: Add the following code snippet before the
ga('send', 'pageview');
line on each domain’s tracking code:javascriptga('create', 'UA-XXXXX-Y', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['example2.com']);
Replace
'UA-XXXXX-Y'
with your property ID and'example2.com'
with the domain(s) you want to track.
Step 4: Update Referral Exclusion List (if needed)
If you have multiple domains with shared sessions, you may need to update the referral exclusion list to prevent self-referrals.
- Navigate to Admin: Go to your Google Analytics account and navigate to the Admin section.
- Property Settings: Under the Property column, click on “Tracking Info” and then “Referral Exclusion List.”
- Add Domains: Add all related domains (e.g., example.com, blog.example.com) to the referral exclusion list to ensure accurate tracking.
Step 5: Test and Verify
- Test Tracking: Visit your websites and ensure that sessions are tracked correctly across domains.
- Real-Time Reports: Use Google Analytics’ real-time reports to verify that cross-domain tracking is working as expected.
Step 6: Analyze Reports
Once set up, analyze the reports in Google Analytics:
- Audience Reports: Understand user behavior across domains.
- Acquisition Reports: Track traffic sources and user journeys.
- Behavior Reports: Analyze content performance and user engagement.
Additional Considerations
- Subdomains: Cross-domain tracking also applies to subdomains (e.g., blog.example.com).
- Cookies: Users must have cookies enabled for cross-domain tracking to work effectively.
- Consistency: Ensure consistency in naming conventions and configurations across all tracked domains.
By following these steps, you can effectively track website performance across multiple domains using Google Analytics, gaining valuable insights into user behavior and engagement across your online properties.