Tracking subdomains on Google Analytics 4 is a crucial part of monitoring and evaluating the performance of your website. With precise subdomain tracking, you can obtain valuable information about user behavior on various sections of your site. In this guide, I will walk you through the process of enabling subdomain tracking on Google Analytics 4 and provide some helpful tips and insights along the way.
Step 1: Setting up Google Analytics 4 Property
In order to track subdomains, you must first create a Google Analytics 4 property for your website. If you haven’t done this already, head over to the Google Analytics website and follow the instructions to set up your property.
Step 2: Configuring Cross-Domain Tracking
Once you have your Google Analytics 4 property set up, you need to configure cross-domain tracking to include all your subdomains. To do this, you need to add the following code to the head of each page on your website:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=YOUR_MEASUREMENT_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'YOUR_MEASUREMENT_ID', {
'linker': {
'domains': ['example.com', 'subdomain.example.com']
}
});
</script>
Note: Replace “YOUR_MEASUREMENT_ID” with your actual Measurement ID provided by Google Analytics.
Step 3: Updating Analytics Configuration
After adding the code to your website, you need to update the Analytics configuration by adding your subdomains to the Referral Exclusion List. This ensures that user sessions between subdomains are not counted as referrals, providing a more accurate representation of user behavior.
To update the Analytics configuration, follow these steps:
- Go to your Google Analytics 4 property settings.
- Navigate to the “Data Streams” section and click on your website’s data stream.
- Scroll down to the “Enhanced Measurement” section and click on “Configure” next to “Referral Exclusion List”.
- Add each of your subdomains to the list.
- Click “Save” to update the configuration.
Step 4: Testing and Verification
After completing the above steps, it’s crucial to test and verify that subdomain tracking is working correctly. To do this, open your website in a browser and navigate to different subdomains. Then, open the Google Analytics Real-Time reports to check if the traffic from the subdomains is being accurately tracked.
During the testing phase, I recommend using the Google Tag Assistant extension for Chrome. It allows you to verify if the Google Analytics tracking code is firing correctly on each page and provides valuable insights into any potential issues.
Conclusion
Tracking subdomains in Google Analytics 4 is an important practice for understanding user behavior across different sections of your website. By following the steps outlined in this article, you can accurately track subdomains and gain valuable insights to help optimize your website’s performance.
Remember, accurately tracking subdomains is vital for making data-driven decisions and improving user experience. Take the time to set up subdomain tracking in Google Analytics 4, and you will be rewarded with valuable insights that can shape the success of your website.