Tracking & Separating Subdomain Data under One Profile Using Filters in Google Analytics
ByIf you have one Google Analytics profile tracking multiple subdomains (or you want to do so); for example, one profile tracking:
http://www.MyCoolWebsite.com
http://blog.MyCoolWebsite.com
http://youlove.MyCoolWebsite.com
when you view your Google Analytics data in the profile that is tracking all 3 subdomains it won’t by default separate out the data for each actual subdomain. You’ll need to add some additional code to your tracking script and also set up an Advanced Filter.
If each of your subdomains has pages that are named the same, you will see the data reported as aggregate for all them under that page name, therefore the data for those page names will be inflated and not actionable. For example:
http://www.MyCoolWebsite.com/contact.html
http://blog.MyCoolWebsite.com/contact.html
http://youlove.MyCoolWebsite.com/contact.html
will all be rolled up under /contact.html and you will not know what the true data is for the contact.html page on each subdomain. Instead, you will have one entry of /contact.html displaying the data for all traffic to contact.html on all 3 of the subdomains. Not good!
What you will want to do is see it by subdomain so you can attribute the correct data to the correct subdomain.
Luckily, this is easily fixed!
If you already have your pages tagged with the Google Analytics tracking script, just add the line in bold to your existing Google Analytics code (replace MyCoolWebsite.com with the actual domain, not the entire subdomain and of course make sure all of the sites have the same profile tracking number (seen below as UA-xxxxxx-x, the x’s will be replaced by your own account number and profile number).
If you haven’t added the Google Analytics tracking script to your pages add the entire code below – again with your own specific Google Analytics account number and the profile number, and your actual domain:
<script type=”text/javascript”>
var gaJsHost = ((”https:” == document.location.protocol) ? “https://ssl.” : “http://www.”);
document.write(unescape(”%3Cscript src=’” + gaJsHost + “google-analytics.com/ga.js’ type=’text/javascript’%3E%3C/script%3E”));
</script><script type=”text/javascript”>
var pageTracker = _gat._getTracker(”UA-xxxxxx-x”);
pageTracker._setDomainName(”MyCoolWebsite.com”);
pageTracker._initData();
pageTracker._trackPageview();
</script>
Next, you will need to set up an Advanced Filter, this will actually separate out the subdomains so that they will be reported separately under that profile:
The finished result is that instead of just 1 instance of /contact.html, you will see it reported in your reports with each subdomain added to /contact.html as follows:
www.MyCoolWebsite.com/contact.html
blog.MyCoolWebsite.com/contact.html
youlove.MyCoolWebsite.com/contact.html
Here is how to set up the Advanced Filter for Tracking and Separating out Subdomains:
- First log-in to Google Analytics.
- Select edit from the profile you created that will track all of the subdomains.
- Select edit in the Filters Applied to Profile section.
- Fill in the below information and Save.
First, here is the actual information for you to copy and paste, then below that is a screenshot of how it should look before you save and apply it to that profile.
Filter Type: Custom filter > Advanced
Field A: Hostname
Extract A: (.*)
Field B: Request URI
Extract B: (.*)
Output To: Request URI
Constructor: /$A1$B1
![]()
Related posts:
- Google Analytics Filter: Force URI Case to Lowercase Prevent Duplicate Line Items in Google Analytics Due to Mixed...
- Google Analytics App for the iPhone – A Quick Review The best Google Analytics App available for the iPhone right...
- Activating Google Analytics Site Search in 60 Seconds or Less Setting up basic Site Search within Google Analytics to gather...
- Testing Video Engagement Using Google Website Optimizer Using Minimum Viewing Time as a A/B Test Conversion Goal...
Related posts brought to you by Yet Another Related Posts Plugin.
Leave a Comment
You must be logged in to post a comment.
