How to Filter By Subdomain in Google Analytics

Most of the time, checking out your website’s performance in Google Analytics is a snap.

With a few clicks, you can observe your traffic, user information, and generally just how awesome your site is doing.

But what about those pesky subdomains?

You know, the add-ons to your site, like your blog or shop. How can you tell just how much traffic they’re generating?

There are plenty of questions around subdomains and Google Analytics but the most basic is simply figuring out how much traffic is going to them.

We’re here to help you answer it.

Keep in mind that if you’re looking to filter out specific external domains that are counting as false traffic in your GA reports (such as spam referral sites and bots), we’ve covered that topic in a separate post which you can read here.

However, if you’re looking to track and analyze the traffic on your own website’s subdomains, you’re in the right place.

Keep reading to learn the importance of subdomain tracking and how you can accomplish it quickly and easily in Google Analytics.

Need To Filter Subdomain In Google Analytics 4?

Check out this video for an explanation of how to create filters for Google Analytics 4. For a written explanation, scroll down the page.

Why Would I Use Subdomains At All?

Subdomains serve as add-ons to your primary website. They can be helpful because they function separately from your principal domain, but they still fall under your same domain name. This means you have the freedom to add new features or design edits to your subdomain while still having it be under the same umbrella as your primary domain.

Blogs, shops, web apps and learning portals are the most common use cases for subdomains.

For example, if you’ve ever taken a course with us, you’ve probably noticed that our learning platform is my.datadrivenu.com which is a subdomain of datadrivenu.com.

In order to see the data of subdomains, you first need to track the data. Fortunately, that’s super easy in GA4. 

How to track subdomains in Google Analytics 4?

Tracking the traffic on your subdomains in Google Analytics can appear tricky at first, but really, it’s quite simple in GA4. 

All you, or your developers, have to do is add the tracking script of your GA4 property to your subdomains. 

To make sure this was done correctly, you can use the real-time report and the debug view.

24 to 48 hours later, GA4 will contain data from your subdomains. 

Using a dimension to filter by subdomain in GA4 reports

The default settings in GA4 allow you to see when users move between your domain and your subdomains. The fastest way is by using the Hostname dimension in the standard GA4 reports. 

You can, for example, use this in the Engagement report as follows.  

Go to “Engagement” and then “Pages and screens” in the left-hand panel.

Then, add hostname as a secondary dimension in the table. Now, you can see the data from  your users on your main and subdomains. 

To view other data of your subdomains, you can also use “Hostname” as a secondary dimension in other reports, such as:

For a quick analysis, this is a convenient way. But if you analyze traffic of your subdomains regularly, GA4 offers you a smarter solution.

We have already described how to create a custom report in GA4 so what follows is a quick guide on how to create a report that includes the traffic from one subdomain only.

How to create a custom subdomain report in GA4?

To create a custom report for a subdomain or subdomains of your choice, follow these steps. 

Step 1

Open the default traffic acquisition report

Step 2

Click on Add filter

Step 3

In the Build filter panel, choose include and search for Hostname

Step 4

Select the subdomains you want to include in your filter (and report). Alternatively, you can exclude subdomains from the report.

Step 5

Click Ok and then Apply

Step 6

Click on the Customize report icon

Step 7

Save your subdomain report as a new report. To keep your original report untouched, click on the Save button and choose Save as new report.

You can now access your custom subdomain report in the report library. 

Excluding subdomains in GA4

So far, I have explained how to include subdomains in your GA4 account and reports. 

But an equally important aspect of analytics is to exclude data you don’t need.

You can have many good reasons to exclude subdomains completely from GA. Think, for instance, of a subdomain you use as a staging or development environment for your live website. 

The easiest way to exclude all the traffic is to NOT install the GA tracking code on them.
In those cases you want to track subdomains and you have installed GA4 on them, you can simply use Exclude in the Build filter of your reports.

As described above, you then use the Hostname dimension and select all subdomains you want to exclude from the specific detail report, or your custom report. 

Conclusion: analyze subdomains that matter to you

Google Analytics is an important tool when it comes to tracking and analyzing how people behave on your website and how they find your site.

If subdomains are a vital part of your business, make sure that you track these too. This is rather easy in GA4.

The same goes for filtering subdomains in reports and even setting up custom reports that include, or exclude your subdomains.

Show Buttons
Hide Buttons

Save $2,000 and enjoy lifetime access to Data Driven Insiders and our upcoming live Meta Ads Blueprint course.

Scroll to Top