Guide to Tracking Multiple Subdomains in Google Analytics

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.

Filter to show full domain (including subdomain)

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.

Filter to only include traffic to the specified subdomain

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.

Wrap Up

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.

Perhaps the best way would be to apply the filter to your Google Analytics account that I describe above that will allow you to view the subdomain in your page list. Then you can use the search function in Google Analytics to isolate the subdomain you want to view.

I have implemented the set up as described and also the filter set up. Should I create the filter for each sub domain or just one config applies for all the sub domains? Analytics gives the option to implement the filter on the sites. So should i use this option for further configuration?

If yes, the best advice I can give you is to apply the filter that I mentioned in the post for displaying subdomains in your main profile. If you apply that filter then you can at least see the subdomains in your main Google Analytics profile.

Hi- In your post you say “Do not create a new Google Analytics account for each subdomain.” Can you address creating a new web property and contrast that to using profiles instead? Many of the GA reference sites show examples of web properties being used for things like blog.example.com or m.example.com. We implemented two web properties for primary and m. and are finding out that maybe we cannot get a total data view of the primary domain and the subdomain. Maybe this is the main advantage of doing the one “account/web property” and profile technique instead? Is this correct?
Thanks,
Karen

If you have the subdomains separated out into their own account then you have no easy way to get an over view of the entire site with all subdomains. Maybe you want to be able to view your blog.website.com, m.website.com, and http://www.website.com all at once. In this scenario you have to piece information together from the various accounts.

That is why I recommend creating one GA account and then creating a new profile for each subdomain while keeping one “master” profile that has data for every subdomain.

I’ve set up my two sites (http://www.natecarrier.com and http://blog.natecarrier.com) with a single Google Analytics account as the post describes. I noticed later, though, that in order to view the organic search queries of search engine traffic, you need to link the GA web property to your Webmaster Tools site (see http://googlewebmastercentral.blogspot.com/2011/02/linking-google-analytics-to-webmaster.html). From what I’ve found (and my own attempts), you can only link the GA web property to one Webmaster Tools site. This means that I can link my GA account to my www site on Webmaster Tools, but not to my blog site. Without being able to link both, I can only see organic search queries that led to my www site, but not my blog site. That’s unfortunate.

Are there any solutions or workarounds to this problem? All I can think of is toggling the association back and forth whenever I want to view reports of search queries for one or the other. It doesn’t look like the association can be made at the profile level, only the property level.

Looks like I was mistaken. The organic search report is populated regardless of whether you have set up Webmaster Tools (and therefore works for both subdomains). However, the reports under Search Engine Optimization do require Webmaster Tools, as far as I can tell, you can only see reports for the subdomain you’ve chosen to associate.

Great guide! So when I got this setup for my multiple subdomains, and want to define conversion goals based on target addresses. Normally for http://www.mysite.com/thanks.html I would enter just /thanks.html, but how do I enter the target page when multiple subdomains? There might actually be TWO pages with /thanks.html (one on each domain).

Question #1 – I can view both hostname for each of the three domains in the “realtime” view for the profile “mydomain.com”, but I do not see the hostname when I view the “realtime” view the other profiles (sub1… and sub2…). Can you suggest why?

Question #2 – As I mentioned above I can view the realtime reports for each profile, but I cannot see the “standard reports” for each profile which is all of my historical records, other than the default profile (mydomain.com). Can you suggest how I enable this?

1) Are you sure you set up the hostname filter correctly for sub1 and sub2? If you have 3 profiles, remember that you must set the hostname filter in each profile. Is this problem just in the realtime view? Or does the filter appear to be working correctly otherwise? Maybe a better question is, do you need the filter for these profiles? Theoretically you wouldn’t need to see the hostname in sub1 and sub2 if you set up the profile correctly.

2) If I understand your question correctly, one thing to keep in mind is that when you create a new profile or create a new filter, it only takes effect from that moment forward. Unfortunately Google Analytics does not port over your old data when you create a new profile and it does not adjust your historical data when you create a new filter. Perhaps this is a point I should make in my main post.

1) The domain, and subdomains appear in the realtime view only, not the Standard reports (e.g. Standard Reports > Content). Each profile has been setup with the same filter to view host name (Hostname (.*), RequestURL (.*), and RequestURL ($A1$B1). When I view the individual subdomain’s profile you are right I do not need to see the hostname, but when I view the primary host’s domain where I want to see the totals across all sites it would be handy see this in the Content reports.

2) This answers my question – I had hoped to see the historical reports with the added hostname.

I’ve got it mostly working. My original and only profile before was http://www.muschamp.ca, I deleted a filter that was on that profile and then created a profile just to include www. traffic. I created the filters and profiles for all the other subdomains and then a new master profile but I kept my original http://www.muschamp.ca profile.

The problem I’ve noticed after letting people hit against my website for a couple hours is the original http://www.muschamp.ca profile still contains traffic from blog.muschamp.ca etc. I thought it was old data so I switched to just showing today’s data and let several hours past but it still seems to be showing everything.

Every other profile that I created following the article seems to be performing as expected. Should I delete my original http://www.muschamp.ca profile and create a new http://www.muschamp.ca profile or will this eventually go away?

Thanks again for posting this technique, it is a good way to deal with multiple subdomains.

The thing to remember is that the filters do not effect data that was created prior to entering the filter. When you create a filter it only effects data from that moment forward. So your old data will still show normally while new data takes the filter into account.

Took a look at my analytics today and it looks good, but what about Webmaster Tools? Now that I have multiple profiles is there a good way to associate each subdomain that I’ve claimed in Webmaster tools with the profiles I’ve created in Google Analytics.

It seems Google analytics expects me to have only one Webmaster tool verified domain. I’ve uploaded the file to each subdomain and made Webmaster Tools happy but the keyword suggestions seem odd both for “All traffic” and for other profiles…

It doesn’t seem possible to get webmaster tools to share keyword display data for subdomains using this technique. The All Traffic profile gets data and then for the subdomains they seem to get the same data as the All Traffic ie the default profile.

It is not surprising that Google Webmaster Tools would have trouble with this. You may need to create a new site in Google Webmaster Tools and verify each subdomain independently (one Webmaster Tools account for www and another for blog). I’m not entirely sure that would fix the problem, I doubt GA and Webmaster Tools communicate this stuff well to each other.

This is a fantastic post! Quick question, however – we are on the new Universal Analytics that Google recently rolled out. There is no section in Settings where you can find Tracking Code -> One domain with multiple subdomains. Does this post solely apply to Google’s Classic Analytics product? Again, thank you so much for your fantastic post!

What if I would like to separate one of my subdomains into a dedicated profile. If I use a new GA code I will lose my previous data. Can I pull out a sub-domain w/o losing previous data? Is there a way to import/ recover the old data?

Tried implementing this. It affected real time analytics tracking (where nothing appears on real time data even though people were visiting our pages) which in the process affected our traffic reports too. Had to remove the filters.

I discovered a new quirk of this technique. In my “All Traffic” I created a goal, a destination goal. It says don’t use the entire path, just use /filename.html so I did that. I could never achieve the goal. Then I went to my www. profile created the goal and voila it said 17% of my viewers in the last 7 days had complete my hypothetical new goal.

I don’t know if this applies to all goals, but apparently to destination goals the fancy filter profile affects your ability to create destination goals.

You may have to adjust the goal account for the new filter. It appears that others are having issues with destination goals so the filter may be conflicting with the goal. I will be looking into this and trying to figure out a solution.

My guess is that you can literally visit either version of those pages. Typically, it is recommended that you redirect the non-www version of the site to www. So, a user shouldn’t be able to visit both www and non-www.

Hi, I have some troubles with the “Set Up Profiles For Each Subdomain” step. The main domain is being tracked well. I am adding a subdomain.
I have already put the new tracking code to both main domain and subdomain.

If I were you, I would create 3 profiles. 1 for the main domain, 1 for the sub domain, and 1 that combines them. You could easily get by with only 1 profile that collects data on both of them if you wanted to, just make sure to do the ‘display subdomains’ filter.

You can input the exact string that you see in Behavior -> Site Content -> All Pages. So if your page was /something/something.html before the filter, and after the filter it is subdomain.domain.com/something/something.html then you would use subdomain.domain.com/something/something.html for the goal.

Hi, I did this exercise and it works great. (I’m building my subdomain now so it’s not tracking yet) So I have only two domains I’m tracking http://www.soccertalk.us and ALL (which incorporates www. and the subdomain I’m creating) I’m only tracking the www. and ALL right NOW. But, I noticed that the numbers from www. and ALL don’t show the same numbers even though my subdomain shop.soccertalk.us isn’t created yet. I would assume the www. and ALL would be showing the same unique visitors? There is a pretty large discrepancy. Please advise if you don’t mind:) Thank you.

I have a set up like you describe. One profile is rolling up the main domain plus the two subdomains and I have separate profiles for the two subdomains. My question is I also want a profile that excludes the subdomains so that I have a view of only the main domain. Is this possible and if so how?

I have a domain with 2 subdomains, and I set it up as you described. But I later started to wonder if it’s necessary to create the individual views for each subdomain. Couldn’t you just use Custom Segments on the main View, that filters on the hostname? What is the benefit of creating a separate View for each subdomain, compared to creating Custom Segments?

Hey, I’m tracking my main domain (www.phnxboards.com) and it’s store subdomain (store.phnxboards.com) and I created a filter according to your instructions so I can see the full path. My problem is now I see the http://www.phnxboards.com/ in front of every page, even though it is the home page and it should just appear in Google Analytics as /. I want all pages off the main domain (for example, http://www.phnxboards.com/about) to appear as /about, and all pages on on the store (for example store.phnxboards.com/collections/all) to appear with the subdomain so I can tell when people are on the store. I’ve been researching how to do this for hours and am stumped and confused. Any help would be much appreciated! Thanks, PHNX Boards.

A simple but maybe stupid question: I have just the standard tracking set up (no setDomainName) on one domain and one subdomain. What are the problems with sorting the pageviews by pagetitle? (The subdomain has a different pagetitle than the index page on the domain so i can easily differentiate between the two in Analytics)

Thanks for the info. I’ve followed all the instructions, but I am still not seeing any goal conversions for the main view (soundslides.com) when I click on the subdomain (soundslides.com/store) it is only here that I can see when the form is successfully filled out. Any help would be appreciated.

I’m not seeing any option in Analytics under Tracking Info re: tracking subdomains. All I see is code for Universal Analytics. Has this been updated in the last 2 weeks? It seems like the only option is to manually add the set domain code to all pages of the site, whereas in the past Analytics would do it for you automatically as you explain here. Thoughts?

First off, this is an excellent looking guide and I’m sure it works for all you techies. But Google Analytics makes things like this far too complicated for mere mortals like myself. So I look for alternatives. There may be another way around this – instead of having subdomains, why not just have folders? Then you can just do a redirect from your old subdomain to the new folder. e.g change “blog.yousite.com” to “yoursite.com/blog”
No need to mess with GA code if you have simple folders.

Yes. This is a bit tricky, but for destination goals you need to make sure that the string you enter as the destination matches exactly what displays as a page in Google Analytics. For example, if you used the filter to show the subdomain, your destination goal that used to be /something/goal.html will now be subdomain.domain.com/something/goal.html