Subdomain Tracking with Google Universal Analytics

In today’s video post, we’re going to tackle a simple way to get Google Analytics to recognize that traffic to your root and subdomains should be treated as a single session while maintaining the correct traffic source and most importantly, not reporting self referrals.

Steps for setting up subdomain tracking in Google Analytics:

  1. Install GA code. Default UA code, all subdomains.
  2. Create views, filters and exclusions.
  3. Test
  4. Celebrate your accomplishment!

Note from the video:

When setting up the ‘Show subdomain filter’, here’s what you need:

Filter Type: Custom, Advanced

Field A -> Extract A: (.*)

Field B -> Extract B: (.*)

Output To -> Constructor: $A1$B1



Check out our Google Analytics Course on

2018-01-08T11:18:02+00:00 Web Analytics|

About the Author:

My name is Rick and I've enjoyed building websites and doing digital marketing (as a profession) since 2002. My background is mostly in search, social and email marketing. I specialize in data driven marketing and marketing automation on small and large scale. Reach out anytime!


  1. CurlsUnderstood March 11, 2015 at 8:08 pm - Reply

    Hi Rick,

    Thank you so much for this video it was really helpful! I followed your instructions down to a tee (many times) and when I view my sub domain’s real time activity the active pages are from my main domain ( when it should be

    Note that I used the UA analytics code for both my main domain ( and sub domain (; I created the view, set up the advanced filter, added to the referral exclusion list then cleared my cookies.

    Any idea what could be going on?


    • Rick Maggio March 12, 2015 at 12:56 pm - Reply

      Hi Sylvia,
      I haven’t seen that before but would be glad to take a look (for my own curiosity). I’m going to shoot you an email to get some info.

    • jimecalfa April 28, 2015 at 7:08 pm - Reply

      Have the same situation here. Any solution?

    • Alexandre Do Nascimento June 27, 2015 at 8:41 pm - Reply

      I have the same situation here

    • Alexandre Do Nascimento June 28, 2015 at 1:36 pm - Reply

      Im sorry. It was just a case of waiting 24hs to this config takes effect. Now its working fine.

      • Rick Maggio June 29, 2015 at 11:40 am - Reply

        Glad to hear that you have it working. One thing to bear in mind is cookie duration. Typically, returning visitors will still cause self referrals until the cookie runs out.

  2. Tracy March 13, 2015 at 12:36 pm - Reply

    This was great and helped me solve this exact problem right away. Thanks!

    • Rick Maggio March 13, 2015 at 12:42 pm - Reply

      Glad to hear it, you’re welcome!

  3. Jason June 12, 2015 at 6:08 pm - Reply

    Very helpful. Thank you!

  4. Jason Hagen October 2, 2015 at 12:41 am - Reply


    Thanks for the video! It was a great big help. One thing I am trying to figure out is how to view individual hits per subdomains. I’m fairly new to Google Analytics so maybe I just don’t know what I am looking for. I would like to make separate reports for each subdomain (ex. blog, store, etc.). What would I use in the filters to do this?

    Hopefully my question is clear enough.

    Thanks in advance,

    • Rick Maggio October 2, 2015 at 12:16 pm - Reply

      Hi Jason, I’m glad it helped. There are a number of ways to get a view by subdomain.

      One way to do it would be to create a segment (or many segments) for ‘hostname’ and include/filter the subdomain. Segments are configured within the view reporting (in case you’re not familiar).

      Alternatively, you could create separate views for each subdomain (via filters).

      I think it somewhat depends on the structure of the site and how much fo the traffic is bouncing between sub-domains.

      Hope this helps,

      • Jason Hagen October 2, 2015 at 3:51 pm - Reply


        The way I have my site setup is that I have a subdomain for my blog, another for my portfolio of my work, and onefor an online shopping cart.

        I was wondering if you could make a short video and show of both methods and how the data is shown in Google Analytics. That would help me decide with method is better.

  5. Namee Trivedee Jani October 23, 2015 at 11:05 am - Reply

    hi rick,

    we have subdirectory website, for example

    I created new view as you show in video as well as same filter as per video.
    Also completed Referral Exclusion but still I can see url like, and etc when I open specific view newwebsite

    Please help me, I did anything wrong?

    Namee Jani

    • Rick Maggio October 23, 2015 at 12:14 pm - Reply

      Hi Namee,
      This tutorial is for subdomains ( as opposed to sub directories ( What is your goal with this implementation?

      • Namee Trivedee Jani October 24, 2015 at 10:02 am - Reply

        Hey Rich,

        Thanks For Reply.

        Out client lunch micro website through main website.

        For Example, is our main website which contain all projects but which new real estate project by our client with totally new design & new content, Menu etc.

        I applied all stuff which you suggested but as I described I failed to get exact data… I guess because which you explained is for sub domain not for sub directory.

        If my new website is like than I can say it will definitely work.. I really appreciate that you explained very well…

        Thank for sharing… 🙂

        Now coming to the point that my website is sub folder website…


        Step 1. Go to Admin
        Step 2. Create View
        Step 3. Filter

  6. Richard Horne November 25, 2015 at 12:17 pm - Reply

    Hello Rick,

    I have followed your instructions and set up our analytics as you’ve described, however, when we try and view Search Engine Queries under the Acquisition section of GA, we are only seeing a handful of queries from our main domain and not from any of the subdomains.

    If I view the search console, I can see queries for each of the websites, but they’re just not all showing up grouped together in the main report.

    Do you have any suggestions?

    • Rick Maggio November 25, 2015 at 1:51 pm - Reply

      Hi Richard. The search engine queries data comes from google webmaster tools, not google analytics (even not though it appears there). The only way to view organic queries for your sub domain in google analytics is by drilling in to the channels reports. To view more query data than that, you’d need to set up multiple webmaster tools profiles. Hope that helps.

  7. Alex Ghostaunt January 12, 2016 at 2:16 pm - Reply

    Hello Rick,
    I have followed your instructions but I have only statistics in the real time view.
    Can we have all data in behavior overview ?

    Thanks for your help.

    • Rick Maggio January 12, 2016 at 6:42 pm - Reply

      Hi Alex, you’ll see it first in Real Time and then about 3 hours later, you’ll see it in the regular GA reports. It takes data a bit of time to get there. Make sense?

  8. Sagi Pomerancblum February 17, 2016 at 12:12 pm - Reply

    Hi Rick,

    I have followed your instructions, but for some reason GA is now collecting data from the sub-domain to the “all web site data” view, although I’ve created the filter only for the new view (so the both view shows the same data).

    Any idea why?

    Thanks (:

  9. DGW March 4, 2016 at 4:55 am - Reply

    Hello, i want to do this to track different languages on a same website, for instance, –> english and –>spanish

    My doubt is, will track all the data not only data on in english??

  10. Altabear June 29, 2016 at 5:19 pm - Reply

    Thanks for the excellent tutorial.

    We had previously just set up the subdomains as their own property and views.

    I just tried setting up ONE of the subdomains under the main website as described in your video.

    I notice that under “configure adwords link group” I can now choose the second view for the “linked AdWords account. Will that screw up any AdWords stats?



    • Rick Maggio June 29, 2016 at 8:27 pm - Reply

      Hi Altabear,
      Great question. If I understand you correctly, you’re concerned about the Adwords link. Adwords accounts can be linked to 1 or many views. You’ll want to link the Adwords account to all views for which you want to pass the click/cost (and other google Adwords data) data. You can pass the Adwords data to many different views. The issue you’ll have is that you won’t have any historical data in the new views.

      Does that make sense and match what you’re seeing?

  11. Zach Blackburn July 27, 2016 at 5:41 pm - Reply

    How do you add a filter to block out all the subdomain traffic?

  12. Vince August 4, 2016 at 5:59 pm - Reply

    Thank you for this!!! I went through and followed this entire tutorial. The only issue I have is that I am still seeing self referrals. I found an article that said to adjust the campaign timeout under session settings but it didn’t give much detail on what this should be adjusted to. Do you have any more information on how I can fix this so it stops reporting these referrals?

    • Rick Maggio August 5, 2016 at 12:01 pm - Reply

      Hi Vince,
      In short, the only self-referrals you should still see are from return visitors since they have been previously cookied. It shouldn’t take more than a month or so for most of these to clear out. Once way to make sure that this is the case is to create a new segment for “new users” which should show 0 (none) self referrals. As long as this is what you are seeing, I would just wait it out as opposed to going through the trouble of resetting the campaign timeout period. Does that make sense?

      • Vince August 5, 2016 at 1:09 pm - Reply

        Awesome. Thank you!

  13. Robert Lamb August 31, 2016 at 3:26 pm - Reply

    This worked great for me – the only question I have is my AdWords Account Data isn’t showing in the “Show Subdomain View”. Any tips?

    • Robert Lamb August 31, 2016 at 4:00 pm - Reply

      I have Linked this new view to AdWords based on your response to a comment below.
      Perhaps it takes some time for these changes to go live?

      • Rick Maggio August 31, 2016 at 4:46 pm - Reply

        Yep, it can take some time! Please keep us posted.

        • Robert Lamb August 31, 2016 at 5:24 pm - Reply

          One more question: If I apply the Filter mentioned here to a View that has been active for a few months, will it be able to filter that past subdomain traffic in reporting? or can it only filter it from today forward?

          Thanks a bunch. Your initial post has already saved me from a major headache down the road!

          • Rick Maggio August 31, 2016 at 8:30 pm

            The filter you added will only filter future traffic. They way you can filter PAST traffic is to use segments (in the reporting section) which can filter past data.

            Does that make sense?

  14. Faizan June 16, 2017 at 6:08 pm - Reply

    Hi Rick! Thanks for the great video. For some reason the filter is not working for me and I don’t see my subdomain in real-time. Why is that?

Leave A Comment