Subdomain measurement in Google Analytics 4

Share this article

In some cases, a business website may use different subdomains for different sections of the site. For example, www.example.com might host the main website, blog.example.com the blog, and checkout.example.com the purchase flow. In those situations, you will usually want to use the same Google Analytics 4 property to track user behaviour across all of them.

In this article, I’ll explain what you need and which steps you should follow to make sure all subdomains are measured correctly and the data is sent to GA4 without any issues.

Before continuing, it is worth mentioning another common case related to this topic. When a business has two separate websites that use different domains rather than subdomains, such as mainwebsite.com and secondarywebsite.com, and you want to use a single GA4 property for both, then you need to configure cross-domain measurement instead.

How is subdomain measurement configured in GA4?

Subdomain measurement in Google Analytics 4 is very straightforward, because GA4 handles subdomains automatically as long as it is installed on all of them.

Google Analytics uses first-party cookies to track users across a website. By default, those cookies are available at the domain level, which means all subdomains can access them and the cookie value does not change when the user moves from one subdomain to another.

To measure all the subdomains of a site together, you just need to make sure they all belong to the same GA4 property and use the same web data stream. In other words, the same Measurement ID should be implemented across all subdomains.

In principle, no additional setup is needed. However, if you notice that one of your subdomains is still appearing in the GA4 traffic acquisition report, you may need to add that subdomain to the list of unwanted referrals in the web data stream settings.

How to check whether subdomain measurement is working correctly in Google Analytics 4

When you access a website, Google Analytics 4 creates, if they are not already present, two cookies: _ga and _ga_[measurement_id]. These cookies are used to identify the user and track their activity throughout the session.

As mentioned above, GA4 cookies are set so they are accessible across the whole domain. Following the previous example, the cookie would be set on .example.com, which means any subdomain of example.com can access that same cookie.

For that reason, to make sure subdomain measurement is working properly, you only need to check the behaviour of those GA4 cookies across the different subdomains.

If you want to verify that the setup is correct, open your website and launch your browser’s developer tools. In Google Chrome, you can do this from More tools after clicking the three-dot menu in the top-right corner. Once the panel is open, go to Application and then open the Cookies section.

Inside the cookies panel, you will see a list of all the cookies the site has stored in your browser. Find the two Google Analytics cookies, _ga and _ga_[measurement_id]. The easiest way to find them is to search for _ga.

Once you locate them, you will see both their value and their domain. The domain is the field you need to check. It should follow the format explained above, such as .example.com.

Then repeat the same check on the rest of the subdomains you want to measure under the same GA4 property. On all of them, the GA4 cookies should show the correct domain, and the cookie value should also remain the same. That indicates the user is being identified consistently across subdomains.

Another way to confirm that the setup is correct is to use GA4 debug mode and review events in DebugView. With this method, you just need to navigate across the different subdomains and check that DebugView identifies all those interactions as belonging to the same user.

How to analyze the data from each subdomain inside GA4

Once subdomain measurement has been implemented, Google Analytics 4 shows the data together. In other words, you will see the events, page views, sessions, conversions, and the rest of the interactions that happened on any of the subdomains.

However, if you want to analyze the data from each subdomain separately, GA4 provides the Hostname dimension.

In our example, the Hostname dimension would contain values such as www.example.com, blog.example.com, and checkout.example.com. You can then use that dimension as a filter if, for example, you only want to see the interactions that took place on the blog subdomain.

As you can see, setting up subdomain measurement in Google Analytics 4 is very simple. You just need to make sure the same Measurement ID is installed on all subdomains, since GA4 handles subdomains automatically.


Share this article
raul revuelta seo y marketing digital

About me

Raúl Revuelta

Digital marketing consultant specialized in SEO, CRO, and digital analytics. On this blog, I share content about these areas and other topics related to digital marketing, always with a practical, business-focused approach. You can also find me on LinkedIn and X.

Leave a Comment

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

Would you like to talk about your project?

Scroll to Top