Last updated on December 2nd, 2014
Tracking multiple subdomains in Google Analytics is a little tricky since there is no “easy” button to push. You will need to configure analytics properly to track and display data correctly.
In this guide you will learn how to install Google Analytics to properly track subdomains and configure Google Analytics to best display the subdomain data. This guide helps you configure Google Analytics to view all of your subdomain data in one place.
Things to Remember
- If you are using destination goals, you will need to update your destination goals if you are going to use this method. Below I note how to use destination goals when tracking subdomains.
- Each Account can have 25 Views. Something to keep in mind if you have a lot of subdomains.
- You cannot alter past data. What this means is that you cannot use this method to alter data on subdomains from the past, only alter data moving forward.
- By default, Google Analytics creates a new session when users navigate from one subdomain to another. If you do not want a new session to be created, go to to Tracking Info -> Referral Exclusion List
- Make sure that all of your views are the same time zone. Seriously. If they are in different time zones you will spend way too much time trying to figure out why the data appears incorrect.
- I recommend creating an extra View that remains untouched. This View should have no filters applied to it so you can compare the data to it if you think something went amiss in setting this up.
This is advanced Google Analytics configuration. If you would like to hire me to help, please contact me for more info. It’s not too late, you can email me and have me do it for you instead of spending days trying to do it yourself.
Install Google Analytics for Multiple Subdomains
The first step in setting up Google Analytics to track multiple subdomains is to install the correct code.
If you are using Universal Analytics then your code is already correct. If you are setting up analytics for the first time then Google will give you the correct code.
If you are not using Universal Analytics; then simply go to Admin -> Property -> Tracking Info and make sure ‘Subdomains of [yoursite]’ is set to On. This will add the following code: _gaq.push([‘_setDomainName’, ‘yoursite.com’]);
You can also manually add the code to your analytics code if you are comfortable doing so.
Note: the code is the same for all of your subdomains. There is no need to adjust it for each subdomain.
Once you install this code on all of your subdomains Google Analytics will begin reporting data from each one. You have more work to do to best display and view this data. Keep reading.
Display Subdomains In Your Analytics Data (Optional, recommended)
In the previous section you set Google Analytics up to track multiple subdomains; this section we will work on displaying the data properly.
By default Google Analytics does not show the domain or subdomain in your data. This poses a problem when tracking multiple subdomains because you will not be able to tell the difference between subdomains in the data.
If you have pages that have the same path on any two subdomains, you will not be able to tell the difference between them in the data. This includes the home page which will only display a forward slash.
For example, if you have two pages like this: www.yoursite.com/contact-us and subdomain.yoursite.com/contact-us they will both appear as /contact-us in your data.
We need to create a filter that will display the subdomain in our data.
Note: this filter will conflict with destination goals. If you are using destination goals, you will need to make sure the destination is exactly the same as the page in the page list (Behavior -> Site Content -> All Pages)
There are two different ways to do this filter
It is important to remember that filters in Google Analytics do not alter historical data. This will be important to consider when choosing which filter to enter.
The filter that you should enter will depend on how you want to handle your historical data.
If you want to show the full path for all of your subdomains moving forward (including www or whatever your “main” domain is) follow the filter below.
If you want to only show the full path for a specific subdomain (this option may be more friendly with your historical data) then do the exact same filter above EXCEPT for the Hostname field enter (subdomain.yoursite.com) with the parenthesis.
After applying one of these filters you will be able to differentiate traffic between subdomains.
Set Up Views For Each Subdomain (Optional, recommended)
Quick note on views. A view is what Google Analytics uses to refer to profiles of data. You can create unique views that will allow you to manipulate the data in different ways for that view without effecting other views.
To best organize your data I recommend creating a view for each subdomain and then another view that collectively allows you to display the data for all of the subdomains.
If you have been following along closely so far; we have already created a view that collects data on all of the subdomains and configured Google Analytics to display our subdomain data. Let’s create a view for each subdomain by going to Admin -> Views -> Create New View.
Once you have created each view, we need to apply filters to make sure each view is only collecting data on their assigned subdomain.
To apply a filter that ensures that we track only traffic for the view’s designated subdomain, go to Admin -> Views -> Filters -> New Filter and refer to the screenshot below.
Applying this filter to your profile will ensure that this profile only tracks traffic for the specified subdomain. In this case, www.yoursite.com. Remember, www is a subdomain itself. Repeat this filter for each profile that you created where you need to isolate a subdomain.
In this guide we learned:
1) Common pitfalls and things to remember (probably a good idea to review the “Some Things to Remember” section)
2) How to install Google Analytics properly for tracking subdomains.
3) How to display our subdomains in our data.
4) How to create views for each subdomain to individually display their data.
Need a hand?
I can take a look at your website, sundomains, and analytics and help you configure it correctly for a one time fee. Please contact me for more info.