Subdomains are a standard way to segment content on a website.
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.
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.
Here is your definitive guide to setting up Google Analytics (GA) tracking across subdomains.
Cross-Subdomain vs. Cross-Domain — What’s the Difference?
Understanding the difference between cross-domain and cross-subdomain tracking is crucial. The methods for implementation across each are entirely different.
To be clear, here is the difference between a (root) domain and a subdomain:
- example.com (root domain): Domains consist of various letter / number combinations followed by their domain extension (.com, .org, .gov, .edu, etc.)
- widgets.example.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.
You would need to implement cross-domain tracking if, for example, you wanted to track users across the following:
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)
- Blog hosting (typically when blog functionality is cost-prohibitive with current CMS)
- E-commerce checkout pages (typically third-party shopping cart solutions)
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:
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:
- Root domain & subdomain DNS settings
- GA account structure
- 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.
Why Track Cross-Subdomain Traffic 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.
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:
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 Analytics Account Structure
The account structure hierarchy in Google Analytics is:
Analytics Account > Properties & Apps > Views
The image below represents how many analytics accounts are set up. This implementation structure consists of the following levels:
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
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.
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.
2) Click “Tags” on the left-hand menu.
3) 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.
4) Click to edit the tag then proceed to “More Settings” > “Fields to Set.”
5) Click “+ ADD FIELD.”
6) Set the Field Name to “cookieDomain” and the Value to “auto.”
Part 2 – Update the Referral Exclusion List
This part is the same for both GTM and hard coded Universal Analytics implementations.
Note: 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.
2) Access the admin panel by clicking the gear icon in the bottom left of the screen.
3) Under the property column, navigate to Tracking Info > Referral Exclusion List.
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).
Pro-Tip: Seeing Hostnames in Google Analytics
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.
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:
- Set the cookieDomain.
- Update the referral exclusion list.