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:
- Install GA code. Default UA code, all subdomains.
- Create views, filters and exclusions.
- Test
- 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 LeanDigitalAdvertising.com.
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 (example.com when it should be my.example.com).
Note that I used the UA analytics code for both my main domain (example.com) and sub domain (my.example.com); I created the view, set up the advanced filter, added example.com to the referral exclusion list then cleared my cookies.
Any idea what could be going on?
Sylvia
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.
Have the same situation here. Any solution?
I have the same situation here
Im sorry. It was just a case of waiting 24hs to this config takes effect. Now its working fine.
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.
This was great and helped me solve this exact problem right away. Thanks!
Glad to hear it, you’re welcome!
Very helpful. Thank you!
Rick,
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,
Jason
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,
Rick
Rick,
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.
hi rick,
we have subdirectory website, for example http://www.website.com/newwebsite/
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 http://www.website.com/property,
ww.website.com/category and etc when I open specific view newwebsite
Please help me, I did anything wrong?
Thanks
Namee Jani
Hi Namee,
This tutorial is for subdomains (blog.website.com) as opposed to sub directories (website.com/blog). What is your goal with this implementation?
Hey Rich,
Thanks For Reply.
Out client lunch micro website through main website.
For Example, http://www.website.com is our main website which contain all projects but http://www.website.com/Newproject 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 newproject.website.com 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…
ex. http://www.website.com/Newproject
Step 1. Go to Admin
Step 2. Create View
Step 3. Filter
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?
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.
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.
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?
Oh yes ! Now it works. Thank you 🙂
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 (:
Hello, i want to do this to track different languages on a same website, for instance, mysite.com –> english and mysite.com/es –>spanish
My doubt is, mysite.com will track all the data not only data on in english??
Hi,
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?
thanks
David
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?
How do you add a filter to block out all the subdomain traffic?
Rick,
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?
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?
Awesome. Thank you!
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?
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?
Yep, it can take some time! Please keep us posted.
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!
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?
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?