GA subdomain tracking works very differently than cross subdomain tracking in Universal Analytics. The good news is that tracking across subdomains is one of the places where GA4 has a big advantage over UA.
The Root & Branch website doesn’t have any subdomains. But let’s say it did. Let’s say that all blog pages like this one lived at blog.rootandbrachgroup.com, while all other pages lived at rootandbranchgroup.com. The first of those would be the subdomain.
- blog.rootandbranchgroup.com = example of what a subdomain looks like
- rootandbranchgroup.com = example of the primary domain
In Universal Analytics we would need to go through a complex set up process to track visitors from the subdomain to the primary domain (and vice versa). But in Google Analytics 4 it’s incredibly easy. It’s so easy in fact that it happens automatically.
I’m not kidding. If that’s all you needed to know you can stop reading now. Maybe you can go read about something more confusing in GA4 like event parameters or the user engagement event. But if you want to understand more about how to access your GA4 subdomain data, you can read on below.
Does Google Analytics 4 Track Subdomains?
Yes, GA4 does really and truly track subdomains. And it all happens automatically as well. That means that if you have one (or more) subdomains, you don’t need to do anything to make sure GA4 is tracking those visitors. As long as the primary domain has the GA4 configuration tag installed, the subdomains will be tracked.
I literally did not believe it myself when I first discovered this, so if you’re still in shock I’ll give you a minute. But it’s true. You just need to make sure your GA4 Measurement ID (the unique identifier in your configuration tag) is properly installed on your primary domain. The rest happens by GA4 magic.
That Measurement ID, by the way, is hidden in the green box below. You see it in your Admin section when you click into your Data Stream. If that sounds confusing, you may want to check these 10 steps to make sure your GA4 property is installed and configured properly.
There are some specific situations that are worth exploring further. Let’s check those out and then look at how we can isolate our subdomain data in GA4.
Can You Track Google Analytics Subdomain Separately?
Yes, you can do that. In fact, there are good reasons why you might not want to combine your Google Analytics subdomain data with your primary domain.
Since Google Analytics 4 will track subdomains automatically by default, the only way to keep things separate is to use a separate GA4 Measurement ID for your Google Analytics subdomain.
That means you’ll need to deploy a different GA4 tracking code on your subdomain. And the best way to do that is through Google Tag Manager, with a different container code for each subdomain that you want to track individually. Within each container code, you can deploy a unique GA4 configuration tag so the various subdomains have different Measurement IDs and, therefore, separate data.
What if My Subdomains Have Different GTM Container Codes But I Want to Track Subdomains Together?
This is possible as well. The primary domain has one Google Tag Manager container code. The subdomain has another Google Tag Manager container code.
With GA4, you can still keep those multiple container codes and track your Google Analytics subdomains together. However, all container codes should hold the same GA4 Measurement ID (see image above) in their GA4 configuration tags.
How to Validate Cross Subdomain Tracking
Here’s how to use Chrome Developer tools to see your Google Analytics subdomain tracking in action. Thanks to Nick Baker (what’s up Nick!) for this tip.
For this example, we want to track Google Analytics on a primary domain (https://www.hrpartner.io/) and a subdomain (https://app.hrpartner.io/) together. We deploy the same Google Analytics 4 Measurement ID on both the primary domain and the subdomain. Is our cross subdomain tracking working?
Open Chrome Developer tools.
Here’s our _ga cookie on the primary domain. Check the cookie domain in the blue box on the left side.
Now, let’s head over to the subdomain. We should still see the same cookie persist from the primary domain to the subdomain if our subdomain tracking is working as we want.
Cross subdomain tracking is working.
What is the Role of Unwanted Referrals in Cross Subdomain Tracking?
Let’s back up a step and define unwanted referrals.
What Are Unwanted Referrals in GA4?
Here’s what Google says about referrals in their support article.
Referrals are the segment of traffic that arrives on your website through another source, like through a link on a third-party domain. Analytics automatically recognizes where traffic was immediately before arriving on your site, and displays the domain names of these sites as the referral-traffic sources in your reports.
If you have an unwanted referral, it’s a traffic source that you don’t want to show up in your traffic acquisition reports.
What Happens When You Add an Unwanted Referral?
Here’s what Google says in that same support article.
When you create these conditions, Analytics evaluates events sent from your website and appends the
ignore_referrerparameter with a value of
trueto every event that matches the conditions (
ignore_referrer=true). This parameter indicates to Analytics that the referrer should not be displayed as a traffic source.
To sum up, all events associated with something on the unwanted referral list get an extra parameter appended to them. That parameter is the ignore_referrer parameter, set to true.
Do I Need to Add My Subdomains As Unwanted Referrals in GA4?
No. Like everything else with GA4 subdomain tracking, there is very little manual work you need to do.
Plus, if you look at adding a new domain to the GA4 unwanted referrals, there is no reference to subdomains. Everything is at the domain level.
Check that out below with all 5 options in the dropdown menu specifically referencing the domain level.
With all this said, I’ve been wrong before. So if you think I’m wrong, drop a comment and tell the world (the small segment of the world interested in GA4 subdomain tracking, at least). I’ll update the article and give you full attribution for being smart while I am less smart.
How Do I See My Different Subdomains in GA4 Reports?
A tricky thing about GA4 is that you won’t see the full URL in many places. Instead, you’ll see the page path, which is everything in the URL that comes after the domain and / or subdomain. You can use secondary dimensions and filters to get to the data you want to see.
The trick is using hostname.
What’s a Hostname in Google Analytics?
The hostname is the place where your Google Analytics 4 tracking code is present. This includes your domain and any subdomains.
How to See Hostname in GA4 Page Reports
The report below is the Pages and Screens report in GA4. The default dimension is to show the Page path and screen class of each URL on your site. This includes all pages on the primary domain and all pages on subdomains. If you want to see what hostname (domain or subdomain) those pages are associated with, add a secondary dimension for Hostname.
Check it out below.
What if I Only Want Certain Subdomains in My Reports?
This is where filters come in.
Hit the filter icon in one of your standard reports to access the Filter builder. You can see this below.
You can use an “Include” filter based on the Hostname dimension. Then, simply select the subdomain or subdomains that you want to report on.
This same approach will work if you’re building an Exploration for your GA4 reporting. That’s it!
Looking for something else? Feel free to leave a note in the comments or on the Root and Branch YouTube channel at youtube.com/@rooted-digital. We’re always looking for new content ideas!
Don’t forget that Universal Analytics data will no longer be processed in that platform beginning July 1, 2023. In other words, now is the time to get more comfortable with GA4.
If you’re still someone learning about GA4 (as I am), I’d recommend checking out this GA4 vs. UA comparison or this list of updated GA4 questions. You can also subscribe to the Root and Branch YouTube channel for an updated video every week or so. I’ll see you there! There are explainers and tutorials for tracking like this.
- GA4 page timer tracking
- Bounce rate in GA4 vs UA
- How to set up a GA4 form submission conversion
- How to see UTM tagged campaign data in GA4
- How to create the Source/Medium traffic report in GA4
- How to set up a custom dimension in 7 steps (and why you need to if you want to see event parameter data)
- Goals in GA4 explained vs UA
- How to link Google Ads and GA4
- How to link Google Search Console and GA4
About Root & Branch
Root & Branch is a certified Google Partner agency and focuses on paid search (PPC), SEO, Local SEO, and Google Analytics. You can learn more about us here. Or hit the button below to check out YouTube for more digital marketing tips and training resources.