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.

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’, ‘’]);

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: and 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 ( 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, 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.

86 thoughts on “Guide to Tracking Multiple Subdomains in Google Analytics”

  1. What if you have more than 100 sub domains. Is there a way to view data per domain without creating a profile for each unique domain?

    1. 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.

      Note: a Google Analytics account cannot have more than 50 Views.

  2. I am using a single GA account to track one domain and several subdomains but I haven’t updated my GA code to include this: _gaq.push([‘_setDomainName’, ‘’]);

    By not including this code snippet, what effects would this have on your data?

    1. The default configuration is to track a single domain. That line of code tells Google Analytics to share cookie information between subdomains.

      If you do not implement that line of code, your own site could appear as a referrer if a user accesses more than one subdomain in one visit.

  3. 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?

  4. Hi,

    I have more than 200 subdomain.
    And a need to know each unique visitor per subdomain.
    Is there a way to view data per domain without creating a profile for each unique domain?

    Regards from French Alps

    1. Do you have Google Analytics installed on these subdomains?

      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.

  5. 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 or 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?

    1. Hi Karen,
      I think you answered your own question.

      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,, and 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.

      Hope that helps.


  6. Hey Eric, Great post! Thank you so much!!

    I’ve a question – might seem extremely dumb.
    When you say add this line to the tracking code,
    _gaq.push([‘_setDomainName’, ‘’]);”

    do i add this to both the main domain, or only to the tracking code for the subdomain?

    Thanks in advance for the answer!

    1. You add that to your tracking code in all your subdomains and main domain. Keep it at ‘’ for across all. Hope that helps!

  7. I’ve set up my two sites ( and 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 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.

    1. 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.

  8. I have to track a website that has ~1000 subdomains.

    Can I put the same code on each page and then use your filtering tips?

    I’m afraid I will run into issue with the limits on accounts and profiles, etc.

  9. Great guide! So when I got this setup for my multiple subdomains, and want to define conversion goals based on target addresses. Normally for 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).

  10. Thanks for this informative post Eric!

    I followed your instructions but have a couple of issues I am hopeful you can help me with (or others who read your blog)

    First, some context:
    * three profiles: (,, .
    * default profile ( has the filter “Show Hostname” set as per your instructions.

    Question #1 – I can view both hostname for each of the three domains in the “realtime” view for the profile “”, 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 ( Can you suggest how I enable this?

    Again, my thanks for your insightful post.

    Regards, Nick

    1. 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.

      I hope that answers your questions. Thanks for commenting!

      1. Thanks Eric for your response.

        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.

        Again, my thanks,


  11. I’ve got it mostly working. My original and only profile before was, 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 profile.

    The problem I’ve noticed after letting people hit against my website for a couple hours is the original profile still contains traffic from 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 profile and create a new profile or will this eventually go away?

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

    1. 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.

      1. 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…

        1. 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.

          1. 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.

  12. 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!

      1. First of all, thank you for exactly what I was looking for.

        Secondly, this was the exact scenario I found myself in. Having several hundred sub-domains and using the new Universal Analytics.

        Just to clarify, no changes are needed to the Google provided .js snippet.

        Your solution got me 90% where I wanted to be.

        My tip/modification

        Field A: (.*)
        Field B: (.*)
        Constructor: \[$A1\]$B1

        This outputs something a bit more useful for myself (and saves a lot of characters by omitting the domain (which is always the same).

        The new URI output:

        Again, thank you!

    1. Hey there,

      I’m trying to set this up too, but I just noticed this message when you get the tracking code: “This tracking code can be used on or any sub-domain…”

      I guess there’s no need to change or add anything now. I just hope that the profiles instruction is still the same.

  13. When implementing this… may be obvious, but which analytics code snippet do we use on the subdomain? The one specifically the “main” profile, or the code from the subdomain profile?

    So, for the main profile, the setAccount reads like this.

    _gaq.push([‘_setAccount’, ‘UA-xxxxxxx-1′]);

    on the subdomain, it reads

    _gaq.push([‘_setAccount’, ‘UA-xxxxxxx-12′]);

    1. The analytics code should be the same for both the main domain and sub domain. In the example you posted, that is two separate GA “properties” (one level higher than “profiles”)

  14. Hi!

    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?

    Thanks in advance!


  15. In each of the profile settings you can configure the Website’s URL, do I use the main URL for each profile or do I use the sub domain address for the mobile one? Does it matter?

  16. 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. :(

  17. 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.


    1. Have you tried using the entire path? I know it said not to, but considering you applied a filter that displays the entire path, it may be looking for an exact match on the string and not finding one.

      1. I haven’t tried that, but I’m not losing sleep over this.

        I was disappointed that I have to login to a different profile to see goals specific to my www. subdomain, I wanted everything on one dashboard, but again I have much bigger problems…

        Thanks for the original post.

          1. 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.

  18. I applied your recommendation to our account a few months back and I’m happy to say that everything looks good so far.

    However, I noticed that when I look in the Master profile with subdomain traffic under Site Content, I see pages listed twice with and without the www prefix.


    Do you have any suggestions on how I can reconcile theses pages? And are the pageviews being double counted to these pages?



    1. 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.

  19. Eric,

    It would be really helpful if you could include a screenshot of what it looks like once you’ve applied the filter for the subdomain details on the main account.

    Just a suggestion to help out others like myself who aren’t familiar what “what you get” when everything is set up correctly.

    Thanks for the great helpful article!

  20. 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.

    When you say to create a new profile for all the subdomains you mean a real profile or a new entity? Please see here:

    If you need a real profile, so I have to create it here:

    I have the main domain (all web site data) and 1 subdomain. Does it mean that I have to just add 1 profile? Or two profiles?

    1. 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.

  21. Great post Erik.
    Question for you. How would you set up cross domain goals and funnels when GA only allows you to define the path when defining a goal?

    Please let me know if this does not make sense.

    Thank you in advance.

    1. 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 then you would use for the goal.

  22. 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 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 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.

  23. Hi Eric,

    Thank you for the helpful explanations. I have a question, I’ve been able to set-up cross domain tracking successful but now have a problem excluding a domain in one of my filters.

    The entry goes something like this: (www\.|^)domain\.com

    The problem is that I wanted to exclude only the “” and I’ve realized it’s also excluded my Brazilian domain “”.

    How can I edit my entry to so that it only excludes the “.com” version and not the “” version?

    Thank you!

  24. Hi Eric,

    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?

    thanks for your time.

  25. Thank you for this guide, I found it very helpful.

    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?

    Best regards

  26. Hey, I’m tracking my main domain ( and it’s store subdomain ( and I created a filter according to your instructions so I can see the full path. My problem is now I see the 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, to appear as /about, and all pages on on the store (for example 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.

  27. Hi,

    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)

  28. Thanks Eric, this post has been super helpful.

    I am using the new Universal Analytics. Is it correct that there is no need to modify the tracking code on the pages by adding:

    _gaq.push([‘_setDomainName’, ‘’]);

    I having problems filtering the subdomains and wanted to rule out this.


  29. Eric,

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

    1. I’m not sure but take a close look at your filters and make sure they are not conflicting with each other. Also look at if they are exact match and make sure they match exactly if so.

      Is it a destination goal? It appears that others are having an issue with destination goals. I may have to look into this further.

  30. Great post Eric, thanks :)

    Should the subdomain use the same Account number as the main domain (and just add the _setDomain call)?

    Or should it have its own account (new UA-) and _setDomain with that code?


  31. Hi Eric,

    Thanks for a great post. One quick question: In your pre defined filter setup, is there a reason why you go for ‘that contain’ instead of ‘that are equal to’?


  32. 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?

  33. 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 “” to “”
    No need to mess with GA code if you have simple folders.

    1. 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

      1. Thank you, thank you, thank you!
        After searching and reading about sub-domain tracking for what seems like forever, I finally ended up here.

        You, sir, are the only person who makes sense on the Internet.

  34. I have this setup and working, but the math never adds up. For example, total sessions will be 100, subdomain A had 30 sessions and subdomain B has 40 sessions. 30 sessions were not tracked by the filters.

    It seems like 30-50% of my sessions are not reported in the filtered profiles.

    Do your numbers always add up?

    1. Make sure each profile has the same timezone. I had this problem before and after stressing about it for a week I realized the timezone wasn’t matching and that was the reason the numbers were off.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>