Do you want to track traffic from different subdomains? For example, traffic from a shop, blog, or knowledge base subdomain? In this blog, I’ll explain exactly how to set this up. Subdomain tracking works differently in Google Analytics 4 compared to Universal Analytics.
Table of contents:
What is subdomain tracking? The ideal subdomain tracking setup in GA4 Testing the setupWhat is subdomain tracking?
You might already be familiar with this concept, but I’ll explain it as clearly as I can to avoid any confusion. Subdomain tracking involves tracking visitors on the main domain and multiple subdomains within a single GA4 property. This way, a visit from a visitor that visits for example both the main domain and the subdomain will be measured as one visit with the original traffic source instead of multiple visits losing the traffic source when switching from one subdomain to another, making it easy to determine the actual source of traffic and how they navigate within and between subdomains.
Example of a main domain:
measurebase.com
Examples of subdomains (these are fictional):
blog.measurebase.com
shop.measurebase.com
support.measurebase.com
If there are many internal links between the main domain and subdomains, or between subdomains themselves, using separate properties can quickly cause you to lose insight into the true acquisition source and how users navigate between domains.Setting up separate properties is also complex and less manageable. That’s why it’s preferable to track this traffic within a single property.
The ideal subdomain tracking setup in GA4
In Google Analytics 4, you can set up subdomain tracking without additional modifications by using the same tracking code for both the main domain and all subdomains. Make sure to use the same stream for the main domain and all subdomains.
You can easily implement the GA4 tracking code through a single Google Tag Manager container applied to all domains.
If you want to view traffic per subdomain, you can filter by the dimension called hostname
.
Testing the setup
You can test the setup using the Debug View. When you enable the debug_mode
parameter on both the main domain and subdomains and visit the various domains, you should see the same ga_session_id
across all domains.