ga4 subdomain tracking

GA4 Subdomain Tracking Explained

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.

ga4 measurement id

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.

 

google tag manager png

 

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.

cookies in chrome developer tools

Here’s our _ga cookie on the primary domain. Check the cookie domain in the blue box on the left side.

cross subdomain cookie on primary domain

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.

Ta da!

cross subdomain cookie on subdomain

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.

list unwanted referrals ga4

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_referrer parameter with a value of true to 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.

ignore_referrer ga4

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.

hostname as secondary dimension

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!

Wrapping Up

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.

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.

click to yt

 

5 replies
  1. User XY
    User XY says:

    I have installed different GTM Container on the each Subdomain and still do not see referral Traffic from any of my Subdomains. I want to see, how much Traffic iam getting from the main page into my subdomain. The main page should be treaded as its an unkown page.

    Reply
    • Zack Duncan
      Zack Duncan says:

      Do you see your page view data for your subdomains in your GA4 reports? I’d check the Pages and Screens report and apply a secondary dimension for hostname to make sure you are getting data. If you aren’t, something is wrong with the GA4 installation on the subdomain. If you are, the data is obviously there but it’s just in how it’s coming through.

      I’d recommend a couple things. One, read this article to see how Google treats referrals for subdomain tracking.

      https://support.google.com/analytics/answer/10327750?hl=en

      Also, you could create a new GA4 property that only tracks your subdomain and then see if your primary site is showing up as a referrer. Good luck.

      Reply

Trackbacks & Pingbacks

  1. […] multiple domains for your business or even if you have multiple subdomains. In Google Analytics 4, cross subdomain tracking is applied automatically, meaning data from blog.yourwebsite.com and yourwebsite.com will all be […]

  2. […] Cross subdomain tracking in GA4 happens by default. You don’t need to do anything in order to set this up. All your […]

  3. […] in GA4, you’d need to add both domains as web data streams within the same property. Cross subdomain tracking in GA4, on the other hand, happens automatically. Both cross domain and cross subdomain tracking are […]

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *