Analytics

How to Track Users Across Subdomains In Google Analytics 4 (GA4)

By Justin Seibert| 11 Min Read | November 7, 2022
LinkedInFacebookTwitter
Setting Up Subdomain Tracking | How to Track Users Across Subdomains

Looking for information regarding subdomain tracking for monitoring users across your entire platform in Google Analytics 4 (GA4)?

Updated: 3/18/2024

GA4 is set-up to handle subdomains automatically if the same GA4 measurement ID is shared across all subdomains of the same root domain.

Dana Schumacher, Senior Digital Analyst at DOM

How much longer are you going to rely on Universal Google Analytics? You are at risk of losing any of your historical performance data in 2023 if you don’t set up and properly configure Google Analytics 4. Learn how the two platforms compare to each other in this blog post – Google Analytics 4 vs Universal Analytics.

Subdomains are a standard way to segment content on a website. Subdomains can be created at any time with no limit and with out a registrar. A common reason to create subdomains would be to differentiate a sector of your business such as “info.yoursite.com” or “tools.yoursite.com.”

From a developer’s perspective, subdomains are integral to utilizing multiple CMS platforms.  For this reason, they have become common across the web.

While subdomains have little benefit from an SEO viewpoint, many websites have plenty of justifications to leverage them.

Configuring Google Analytics subdomain tracking can be somewhat aggravating and extremely cumbersome. If you are still using Universal Analytics and also have the need to setup tracking for subdomains – we strongly suggest setting up GA4 so you can avoid many of the remaining steps.

Despite being the market leader in web analytics, Google has been somewhat ambiguous on how to properly configure Google Analytics to track traffic between subdomains and root domains in an aggregate report (aka cross-subdomain tracking).

If this is your first time attempting to achieve correct cross-subdomain tracking, you’re in luck because this guide has made it simple for you.

Cross-Subdomain vs. Cross-Domain — What’s the Difference?

Understanding how cross-domain and cross-subdomain tracking differ from each other is crucial. The methods for implementation across each are entirely different.

source code text subdomain tracking

To be clear, here is the difference between a (root) domain and a subdomain:

  • directom.com (root domain): Domains consist of various letter / number combinations followed by their domain extension (.com, .org, .gov, .edu, etc.)
  • cctld.directom.com (subdomain): Similar to root domains, except with a series of letters / numbers at the beginning, separated by a period (.)

Use cross-domain tracking when you want a single report that displays user behavior across two domains as if they were on a single domain. Without cross-domain tracking, GA will record a new session every time a user navigates between two or more domain properties.

Trying to set up GA4 cross domain tracking?
We’ve got you covered in this blog post:
4 Steps To Set Up GA4 Cross Domain Tracking

You would need to implement cross-domain tracking if, for example, you wanted to track users across the following:

  • https://example.com
  • https://examplesite.com
  • https://www.othersite.com

Cross-subdomain tracking tracks users and sessions across different subsections of a single domain. We get requests to implement this type of tracking much more frequently than cross-domain tracking.

Some of the most common uses for subdomains include:

  • Foreign language versions of a website
    • de.example.com (<— German version)
  • Third-party marketing solutions/software (such as Marketo, Salesforce, Unbounce)
    • marketo.example.com
  • Blog hosting (typically when blog functionality is cost-prohibitive with current CMS)
    • blog.example.com
  • E-commerce checkout pages (typically third-party shopping cart solutions)
    • checkout.example.com

Please note — in the above examples, the root domain never changed. If you’re trying to track sessions across two root domains, we recommend following a different process.

For website owners with multiple subdomains, you need to implement cross-subdomain tracking if you want to track users across the following:

  • www.cctld.directom.com
  • www.es.directom.com
  • www.directom.com

Technical Side Note

Domain owners can create and manage as many subdomains as they want. Proper DNS configuration of subdomains is vital for tracking users across them.

If you make your way through this guide and are still not seeing proper site traffic across subdomains, it might be a good idea to get a second set of eyes to help identify the issue.

Before you continue, we cannot stress enough how getting the following items properly configured will give you a higher chance of success:

  1. Root domain & subdomain DNS settings
  2. GA account structure
  3. Implementation of the same GA code across all subdomains and the primary root domain

Assuming all of the above is good to go, you are ready to configure cross-subdomain analytics correctly.

If you’re dealing with a website with multiple subdomains, in most cases, you’ll want to configure the same Google Analytics 4 measurement ID/data stream across all subdomains.

Dana Schumacher, Senior Digital Analyst at DOM

Why Track Cross-Subdomain Traffic in Google Analytics as a Single Session?

By default, Google Analytics is not set up with cross-subdomain tracking. As a result, website owners will not have an accurate picture of how a user moved across subdomains and the root domain.

Here’s what happens normally: Every time a user comes to a website, GA tracking notes that visit as a session and begins tracking how that person interacts with a site.

Without cross-subdomain tracking, GA will count a new session every time a user goes from a subdomain to a domain (and vice versa). This means that total sessions are being miscalculated and referral data gets lost.

Translation — there’s no way to tell where a user came from and sessions become inflated.

Let’s say that an organic search user lands on a company’s blog from Google and the blog post lives on blog.example.com. After reading the post, the user wants to learn more about the company and fills out a contact form that lives on the root domain. Without proper subdomain tracking in GA, the conversion data will credit the subdomain as the referral source when really the user first came to the site from organic search.

Without correct referral source attribution, websites can’t tell which channels are the most effective for their goals.

subdomain tracking users across your platform

Most sites want to track user navigation between subdomains that share a root domain and the corresponding root domain as a single session. After tracking is set up, traffic sources, user actions and behavior completed on any subdomain can be attributed to the same user session.

For example, you might have a promotional landing page set up at info.example.com that directs users to purchase products at buy.example.com. With cross-subdomain tracking properly implemented, GA will count users landing on one subdomain and converting on another subdomain as a single session.

Heads Up, You Have Been (Un)Warned

Pulling up Google’s developer documentation for cross-domain tracking will prominently display a fun warning at the very top:

Google's cross-domain tracking warning Direct Online Marketing

If the owner of the world’s most ubiquitous analytics platform suggests that something is complex, they’re probably right.

Our advice — do not let Google psyche you out.

It is true that the code behind this configuration is complex.

However, we’ve pulled off quite a few Google Analytics implementations. We made this subdomain tracking resource easy to understand.

So, have no fear – this guide will walk you through a step-by-step process to follow that will help assure success.

Getting Started — The Typical Google Analytics Account Structure

The account structure hierarchy in Google Analytics is:

Analytics Account > Properties & Apps > Views

Analytics account structure hierarchy Direct Online Marketing

The image below represents how many analytics accounts are set up. This implementation structure consists of the following levels:

Google Analytics Heirarchy structure chart direct online marketing

Note that in the implementation above, all the items in the “Properties & Apps” row have unique tracking IDs. Having an implementation set up in this manner is pretty typical.

On the positive side, this setup makes accessing traffic and behavior across a single subdomain within an account a breeze.

Since every property has a unique tracking ID, the data associated with each domain or subdomain automatically populates as its default view and can be accessed without any further configuration.

On the other hand, this configuration makes it practically impossible to track cross-subdomain traffic.

How to Setup Subdomain Tracking In Google Analytics 4

  • Tools needed: Google Analytics, Google Tag Manager, Google Tag Assistant
  • Time required: 20 min
  • Estimated cost: $0

Figure out how Google Analytics tracking is implemented on your site. This guide will touch on how to set up cross-subdomain tracking for both hard coded Universal Analytics and Google Tag Manager configurations.

Before jumping into implementation, please note that this process will only work if your site is using the Universal Analytics version. For older websites with “Classic Analytics,” it is highly recommended to upgrade to the latest version.

In Google Analytics 4, users can be tracked cross-subdomains without the need for additional code. It should generally be handled using the same measurement ID and leveraging reporting, comparisons, and segments to address different subdomain data views.

If you are unsure which method you have implemented on your site, we suggest downloading the Tag Assistant (by Google) Chrome plugin or consulting your developer.

Part 1 – Set the cookieDomain

A cookie is a piece of code on a website that stores information about a session on a user’s computer.

To attribute the name of the domain in the information contained in a cookie, you will need to set the cookieDomain.

If Universal GA is hard coded on your site:

Congrats! The cookieDomain is set to auto by default, and you can skip right to part 2.

If Universal GA code fires through Google Tag Manager (GTM):

  1. Navigate to and select the container you wish to edit.
Google Tag Manager container edits Direct Online Marketing
  1. Click “Tags” on the left-hand menu.
Google Tag Manager Container Tags Direct Online Marketing
  1. Click on your Google Analytics Tag (In this example, our tag was named “Universal Analytics.” If you are unsure which of your tags is being used to send data to Google Analytics, look for the label “Google Analytics – Universal Analytics” in the “Type” column of the tags table.
Tag for Google Analytics Universal Analytics

  1. Click to edit the tag then proceed to “More Settings” > “Fields to Set.”
  2. Click “+ ADD FIELD.”
  3. Set the Field Name to “cookieDomain” and the Value to “auto.”
Fields To Set In Google Tag Manager For Universal Analytics for subdomain tracking

Part 2 – Update the Referral Exclusion List In GA4

This part is the same for both GTM and hard coded Universal Analytics implementations.

Note: In Universal Analytics, setting referral exclusions does not remove that data entirely. Instead, it just gets removed from the referrals are and gets populated as direct traffic.

In addition to that, there is a possibility that this step is already set up correctly in your account, but it is necessary for analytics to display accurate numbers. It is worth the two minutes it will take to double check. 

1) Log in to Google Analytics and select any view from the account that you wish to implement cross-subdomain tracking.

account view selection google analytics for subdomain tracking

2) Access the admin panel by clicking the gear icon in the bottom left of the screen.

google analytics admin panel for subdomain tracking

3) Under the property column, navigate to Tracking Info > Referral Exclusion List.

google analytics property column selecting referral exclusion list dom blog

4) Your root domain may already be in this table. If it is not, click the “+ ADD REFERRAL EXCLUSION” button and submit your root domain (yoursite.com).

In Google Analytics 4, referral exclusions can be easily set with the tag settings area of the data stream settings in GA4. Once you’ve configured those, GA4 identifies those unwanted referrals by leveraging the parameter “ignore_referrer.”

To review and make changes to your list of unwanted referrals in GA4, navigate to Data streams > Configure TA settings > Show all > List unwanted referrals.

Pro-Tip: Seeing Hostnames in Google Analytics 4

In Google Analytics, reporting will strip the hostname when examining exact URLs. If you’ve gone to the trouble of setting up cross-subdomain tracking, seeing whether someone landed on a subdomain or primary domain is essential context when analyzing performance data.

To see this information, navigate to a report where the primary dimension is a pageview (such as Site Content > All Pages/Landing Pages). Select the secondary dimension dropdown > Behavior > Hostname.

Keep in mind that when adding together.

It’s worth noting here that when you implement GA4, the hostname dimension is populated automatically. This is just one of the many ways GA4 is a less manual and easier to set up than it’s predecessor.

While these considerations are high-level best practice when configuring GA4 for multiple subdomains, we recommend that you also refer to Google’s documentation for more details on this subject.

Dana Schumacher, Senior Digital Analyst at DOM

Conclusion

Implementing cross-subdomain tracking has a reputation for being quite difficult, but it doesn’t have to be that way.  If you followed the steps in the guide above, you should have your implementation correctly set up in no time.

Just remember the two main parts:

    1. Set the cookieDomain.
    2. Update the referral exclusion list.

To get more information on this topic, contact us today for a free consultation or learn more about our status as a Premier Google Partner before you reach out.


Full-Scope Online Marketing Services | justin-seibert-headshot

Written by Justin Seibert

Justin Seibert is the President of Direct Online Marketing. Justin holds a Bachelor of Arts from Vanderbilt University. He contributes a wide range of online business-oriented topics, including the subject of exporting. His contributions can be found on publications such as the Pittsburgh Business Times, AdAge, SES Magazine, and La Voz del interior. Justin and his family enjoy learning about new cultures during their travels.

View Justin Seibert's Full Bio

Related Articles

All Blogs
Zen and the Art of First-Party Data Strategy
By Jim Foreman| 11 Min Read | March 7, 2024

Zen in the Art of First-Party Data Strategy

Table of Contents The Introduction The What and Why of First-Party Data Core Principles for…

Read Article right arrow
SEO for SGE | Google SGE Update | Webinar Graphic
By Jim Foreman| 3 Min Read | January 9, 2024

Google SGE: Future Proof Against SEO’s Biggest Change in 20 Years

Pittsburgh, PA, January 9, 2024 – Direct Online Marketing (DOM), a leader in innovative digital…

Read Article right arrow
Google Analytics
By Jim Foreman| 8 Min Read | December 4, 2023

GA4 Comparisons, the New Segments

Google Analytics 4 (GA4) is the standard tool for tracking and understanding web and app…

Read Article right arrow