Guide To Tracking Multiple Subdomains In Google Analytics

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.

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 (highly 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 show us the subdomain.

There are two different filters to consider

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.

google analytics show domain name filter

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.

Google Analytics Filter Include Only Traffic to Hostname

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


112 Responses
  • Ben Petersen Reply

    Very helpful! Thank you

    • Eric Reply

      I appreciate you stopping by, Ben.

  • Raymond Wong Reply

    Thank for the simple guide.

    Do the the Website URL need to be changed in each subdomain profile?

  • Barry Reply

    Thanks. I’m trying to set up filters for subdomains that are pointed to a 3rd party app – The app lets me customize my analytics code but doesn’t let me customize the domain name. I’ve tried to set up as you said with no results in my reports.

    I set up the filter to show traffic to – below is the filter string I put in the tool:

    Does that look correct?

    Below is the snippet that the 3rd party app generates. Note that MY code info is in the “additionnal” section. Is there any reason code-wise why I shouldn’t be seeing the expected results using my filters as you said above?

    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-19xxxx15-7']);
    _gaq.push(['_setDomainName', 'none']);

    _gaq.push(['additionnal._setAccount', 'UA-17XXXX73-1']);
    _gaq.push(['additionnal._setDomainName', 'none']);

    1, // This custom var is set to slot #1.
    'LoggedIn', // Is user logged in.
    'Yes', // Yes for connected users.
    2 // Sets the scope to session-level.

    (function() {
    var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
    ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘’;
    var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);

    • Eric Reply

      Your filter looks good. I am unfamiliar with your set up but a big difference between the code I used and the code you are using is setDomainName. In your code it is being set to none. Looks like you are trying to use trackPageview to achieve this but I don’t know that you will get the desired effect.

  • Stef Reply

    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?

    • Eric Reply

      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.

    • Poulpator Reply


      Do you find a solution ?

      I have the same problem:
      I need to know unique visitor per subdomain (more than 200)….


  • Kelsey Reply

    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?

    • Eric Reply

      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.

      Thanks to your question, I actually went back and revised that section of this post to better explain this. Thank you!

  • Hranush Reply

    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?

  • Poulpator Reply


    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

    • Eric Reply

      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. By default, Google Analytics does not show the subdomain in your data. If you apply the filter then you can at least see the subdomains in your main Google Analytics profile.

  • Michael Reply

    great article i search a lot and only here and in google analytic help by google i found easy to understand infos, but here is easier from google.
    1) For subdomain filter is it better with ^and$?
    subdomain\.domain\.com or ^subdomain\.domain\.com$ ? why is better the second for you?
    2) For main domain, if i create profile with filter to make sure only for main domain witch filter is better? (include main domain? or exclude subdomains?)

    i have profile without filters,
    profiles for subdomains
    and profile for main domain

    thanks a lot
    - michael -

  • Vy Reply

    Would you advise to set up auto tagging or manual tagging when setting up tracking sub domains within Google Analytics?

  • Thomas Digby Reply

    Cheers for this article Eric. Found it very helpful, works a treat!

  • Karen Nenon Reply

    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?

    • Eric Reply

      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.


      • Karen Reply

        Thanks for the quick response. I’m still sort of confused because in the GA heirarchy there is account followed by web property followed by profile. Technically, I have only one account as per your recommendation but I have 2 web properties in that account. I was assuming that the _setDomainName would make it such that the subdomain in the -2 web property would still be available as data in the primary domain -1 web property. What are the practical uses of web properties if not to separate and roll up like this? Can’t Google make something easy for a change??

        • Eric Reply

          The thing to remember is that you should have one account number between all of your subdomains (example: UA-1234567-11). Setting up multiple web properties will give you different account numbers for each.

          I agree that it is confusing. :)

  • Alex Reply

    Now, in term of the other profile that tracks all subdomains collectively. Do I need to add any filters or special things to this? Or is just creating it good enough?

    • Eric Reply

      Yes, you will want to apply the filter that I have under the header “Display Subdomains in the Main Profile”

      • Alex Reply

        Ah of course! I did that step, and it worked, I just didn’t register I had done it! Thanks for the guide!

  • Shai Alon Reply

    Thanks, awesome post with examples.
    You helped with exactly what I was trying to accomplish! Well done!

  • yskan Reply

    Great post, it helped me a lot with setting up the analytics!

  • Elaine Xu Reply

    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!

    • Eric Reply

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

      • Elaine Xu Reply

        Thanks, Eric!

        I’ve got another question.. After setting it up, I noticed that items in my content report became all shortened. (see picture.
        I’m having a hard time figuring out what’s wrong. Here’s my filter set up for displaying subdomains in the main profile..
        And also, the subdomain is not currently showing up in my main domain report as well.

        This is the tracking code i’m using on the main domain, and the subdomain definitely has line, ” ['b._setDomainName', '']” as well.

        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', 'UA-4236786-12']);
        _gaq.push(['_addDevId', 'i9k95']); // Google Analyticator App ID with Google
        _gaq.push(['_setDomainName', '']);

        (function() {
        var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
        ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘’;
        var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);

        Thanks a ton!!

        • Eric Reply

          Hi Elaine, you have a setup with some things I am admittedly not familiar with. I will try to give you a few tips. It is really peculiar that your urls are appearing shortened. Do you have any other filters that could be interfering? Different filters can act against each other and sometimes wreak havoc on your setup. What I would do if I were you would create another profile that you can use as a testing resource. Hope this helps.

  • Rob Reply

    Eric thanks for this post. It’s exactly what I was looking for. I have it set up now so I will watch my data and see what happens.

    Am I right in saying I need to see data coming in for a few hours before I see the sub domain name appearing in my reports (from the filter)

    Also whats the significance of the ^ and $. Do these need to be in the filter to make it work?

    I am using Google Tag Manager, the same GA code is published into and (in two separate container tags) but both have domain set as

    I will wait and see!

    Thx again, fingers crossed this works, I need to lose those referrer = YOURSELF and losing people in the shopping funnel who come into the funnel as {entrance}

    • Eric Reply

      Hi Rob, I hope it worked out for you. I’ll answer your questions even though I am kind of late.

      1) Yes, you need to wait awhile before seeing your filter take effect. This is because the filter only effects data after it is implemented and it does not effect your old data at all.

      2) Yes you need those to make the filter work. I’m not sure exactly what each one does but they are regular expressions that helps filter data.

      3) Yes your domain should be set as on both.

      Thanks for commenting!

  • Johnny Reply

    Hi Eric,

    Thank you so much for the helpful comments. I’m still a little confused as to get the exact set-up I want…and I felt your instructions didn’t fully explain everything.

    Here’s what I’m trying to do (3 profiles as you said):
    - total profile (shows traffic to entire website… &
    - www profile (shows traffic only to &
    - sub profile (shows traffic only to

    Here are my current configurations:
    - total profile (has the Custom-advanced filter “Subdomains” as you explained)
    - www profile (no filters applied)
    - sub profile (has the Custom-include filter as you explained)
    - my www website has the regular analytics code, my sub website has the analytics code with setDomainName applied

    My questions:
    - What else do I have to do? I want to make sure the sub-domain traffic doesn’t show on my www profile.
    - Do I have to change the analytics code on my www website to have the setDomainName line?
    - Do I have to add any filters to the www profile to tell it to only track www traffic AND/OR exclude sub-domain traffic?

    I’m really sorry I had to type out so much of my problem but I felt your blog post was the most helpful and thorough on the subject and you might know the easy answer. Thank you so much!


    • Eric Reply

      Hi Johnny, thanks for the comment and questions. I’m going to revise this post soon after receiving so many comments and questions and comments like yours will help me address everyone’s pain points in my post.

      Yes, you will have to change the analytics code on your www site to have setDomainName. The setDomainName line should be on all your domains.

      Yes, you will have to add a filter to your www profile to tell it to only track www traffic. Remember, technically www is a subdomain. Bonus tip: remember to set up a redirect to make sure that redirects to

      • Johnny Reply

        Now for my NEXT analytics trick:

        I want to track traffic from only my sub domains, WITHOUT the traffic from http://www.domain:
        - What I did was setup a new profile.
        - Then applied a filter to exclude “www”.

        Would that make sense? Or is there a better, more effective way?

        Thank you,

        • Eric Reply

          Yes that makes sense. :)

  • adtya Reply

    Eric, thanks for the brilliant post. I have been using analytics for years now. However, recently i got the subdomains introduced in my site and your blog was very helpful in setting up the data view in analytics. Thanks a ton!
    I have a question:
    My site is without www and in the rule you mentioned for filter in profile, i added:
    Is this correct?

    • Eric Reply

      Hi adtya, thanks for your encouraging comments! Regarding your question, it looks correct but I’m not great with regular expressions so my advice is to try it and see what happens.

      • aditya Reply

        Hi again Eric!
        While I can view the URLs in my dedicated profile for subdomains, when I try to view the Queries under Search Engine Optimization i see site-wide keywords.
        How can I ensure that in the subdomain profile I see only keywords that got impressions and clicks for the respective subdomain?

  • Mark Reply

    Thanks for this Eric!

    Why do you include the first / in the $A1$B1 rewrite? It looks much nicer without it.

  • Mark Reply

    Also, it looks like the predefined filter “Include Only: traffic to the hostname: that are equal to” works now and the custom filter might not be needed.

    • Eric Reply

      Good comments, Mark. I will have to update my post. Thanks again!

  • Jack Reply

    I had no idea how to effectively track subdomain stats under a single account. Thank you!!

  • Nate Reply

    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.

    • Nate Reply

      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.

      • aditya Reply

        Hi Nate
        Are you able to see filtered Queries data for subdomains separately? Please let me know how.

  • Yamini Sharma Reply

    This is a fantastic resource. Thanks Eric!

  • Alex Reply

    Hi Eric,

    Great post! Exactly what I was looking for! I have a similar issue as Johnny’s except that my predecessor already created multiple accounts for our subdomains and I would like to consolidate them into one account with multiple profiles.

    Would it make sense to take my existing GA profile for and enable subdomain tracking, so that it becomes my “total profile?” I realize that I would then have to update my GA code on all and pages.

    Could I then create the setup that Johnny described (copied below) by creating a new domain profile and subdomain profile?

    - total profile (shows traffic to entire website… &
    - www profile (shows traffic only to &
    - sub profile (shows traffic only to



    • By Eric Mobley Reply

      Tough to say for sure- kind of a judgement call. If you change now it can be tough to compare data from the past but it would be a cleaner setup if you did 1 account and 3 different profiles.

      • Alex Reply

        Thanks Eric. It seems that they haven’t been doing much reporting with the subdomains anyway. We use a marketing automation tool to create landing pages that are linked off of our website that are published from a subdomain. I’m trying to shed some light on how people navigate between our site and these content landing pages.

  • Kyle Akerman Reply

    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.

  • Oscar Reply

    Hi Eric,

    When creating the profiles, under Profile settings > Website’s Url, do we enter the subdomain name , or the same domain name(used in the tracking code) for all profiles?

    • By Eric Mobley Reply

      I would recommend putting in the subdomain in that field. I’m not exactly clear on what the Website’s URL field does but I think putting in the subdomain is a safe bet.

  • long Reply

    hi eric, can you show me a screenshot how the page view look like after apply ‘show hostname’ filter.
    Content -> Site Content -> Pages.
    looks no difference in my site

  • Sven Hålling Reply

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

    • By Eric Mobley Reply

      I see two possibilities. 1. Split them into unique profiles and set up your conversion tracking in each profile (See: “Set Up Profiles For Each Subdomain”) or 2. Show your full hostname in your analytics (See: “Display Subdomains in the Main Profile”) and set up your conversion tracking based off of the full hostname.

  • Matt Cobosca Reply

    Thank you, very helpful!

  • hareesh Reply


    I am able to track the conversion rate for one my website, but not able to do the same with other websites, In other websites for conversation rate for visitors flow I m getting message in google analytic : “You may have applied such a condition as date range, an advance segment or goal for which there is no data or there may not be enough data to show results when sampling is in effect”.

    Can anybody provide me solution for this?

    Thanks in advance

  • alex Reply

    great post, thx a lot.
    google’s help confused me, but things got clear due to your post :-)

  • Stu Reply

    Hi, very good guide! Helps a lot. Thank you!

    A question: I would like to have toghether and (I saw your bonus tip to Johnny about redirecting from one to another but I can’t change that on the hosting enviroment).
    Do you know how can I achieve that filter?

    Thanks in advance!

  • Nick Reply

    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

    • By Eric Mobley Reply

      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!

      • Nick Reply

        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,


  • Zac Reply

    Thank you for such a helpful tutorial!

  • Scott Olivares Reply

    Great post Eric! It was extremely helpful and a problem I’m sure many people have. I’ll be bookmarking your site!

  • Nick Wilson Reply

    Fantastic job. Thanks.

  • Andrea Farr Reply

    This article has been incredibly helpful, thank you!!

    Question, I’ve just added my filters to include only the subdomain results for each profile. Any idea how long it takes Google Analytics to show the change to make sure I’ve done it correctly?


    • By Eric Mobley Reply

      It usually takes around 30 minutes to see the update, in my experience. Could be less, could be more.

  • Piyush Reply

    What is use of $A1$B1 here ???

  • Muskie Reply

    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.

    • By Eric Mobley Reply

      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.

      • Muskie Reply

        Giving it another day then only looking at today’s traffic seems to have done the trick. Thanks again.

      • Muskie Reply

        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…

        • Muskie Reply

          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.

          • By Eric Mobley

            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.

  • Idham Perdameian Reply

    Thanks Eric, your guide help me alot to understand how to setup Google Analytics tracking code.

  • Catherine A Reply

    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!

    • By Eric Mobley Reply

      I’m not really sure Catherine, I’m afraid I do not have any experience with the new Universal Analytics.

      • Just a Developer Reply

        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!

    • Cindy Reply

      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.

      • By Eric Mobley Reply

        I haven’t seen that yet. If you get a chance, send me a screen shot.

  • Artem Reply

    Thank you for the excellent guide!

  • kurt Reply

    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']);

    • By Eric Mobley Reply

      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”)

  • Karl Reply


    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!


    • By Eric Mobley Reply

      If you use a new GA code you will lose your data, Google Analytics does not port over data as far as I am aware.

  • Anthony Reply

    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?

    • By Eric Mobley Reply

      If I understand you question correctly, you can put in the subdomain url there. I believe this is just a label and doesn’t effect anything.

  • Janette Toral Reply

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

    • By Eric Mobley Reply

      There may be something else wrong here. I just checked one of my profiles with the filters and real time tracking appeared to be working fine.

  • Muskie Reply

    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.


    • By Eric Mobley Reply

      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.

      • Muskie Reply

        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.

        • T J Reply

          I’m having a similar problem here. I’m attempting to use destination Goals but can’t get them to fire

          At the top level view (http://) I’m setting the full destination to:

          Is there something obviously wrong with this? Thanks for any thoughts :)

          T J

          • T J

            Just to follow up, I setup 3 different goals on the main view, and none of them seem to trigger:




          • By Eric Mobley

            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.

  • Alex Reply

    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?



    • By Eric Mobley Reply

      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.

  • April Holle Reply


    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!

    • By Eric Mobley Reply

      Sorry, I don’t have a screen shot available right now. I did update that section to try to make it more clear though.

  • Pik Reply

    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?

    • By Eric Mobley Reply

      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.

  • Johnny Reply

    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!

  • René Reply

    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

    • By Eric Mobley Reply

      Great question, I’m not sure, I may have to experiment with that.

  • Reply

    Thanks for writing and sharing this! One thing to update perhaps: Google has changed their language from “profile” to “view”. So you’re not creating a new “profile” but a “view”. About view filters

    • By Eric Mobley Reply

      Thanks for pointing this out. I recently went back and updated this post to reflect the new changes.

  • PHNX Boards Reply

    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.

    • By Eric Mobley Reply

      For anyone reading this I figured it out and addressed it in my post.

  • nate Reply


    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.

    • By Eric Mobley Reply

      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.

Leave a Reply