Updated on February 18th, 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.
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.
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 show us the subdomain.
It is important to remember that filters in Google Analyics 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.
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) How to install Google Analytics properly for tracking subdomains.
2) How to display our subdomains in our data.
3) How to create views for each subdomain to individually display their data.