Tracking Multiple Sub-Domains in Google Analytics
Trace Johnson, Former Former Viget
Some decisions need to be made early in the implementation process. First, you need to ask yourself how detailed and segmented you want your sub-domains. If the site-overlay functionality is something you can’t live without, I don’t suggest following these steps.
Here is a great tutorial on just how to do that.Google Analytics treats every domain, be it a sub-domain or a different URL as unique. This can cause problems when you want to track traffic for multiple domains or sub-domains in one easy access report. To overcome this obstacle we add a line of code to the tracking script. Google’s tutorial can be found here.
The problem with Google’s tutorial is that it doesn’t tell you Field B isn’t required. This tutorial adds a '/' unnecessarily to your data. It may prove to be beneficial for you but I prefer my content reports displaying www.viget.com as opposed to /www.viget.com.
Implementing multiple sub-domain tracking in a single profile
Step 1: Appending the Code
Add the _udn="yourdomain.com" line to the tracking code on all pages of your sub-domain and your main domain:
Step 2: Setting up the filter
Under settings/filters create a new advanced custom filter.
This is exactly how the filter needs to be set up.
You will notice I am not adding any '/' marks to the $A1$B1 string. Google added the '/' to allow them to require Field B. The problem is that many home pages don’t have a Request URI, so by appending a '/' to the URI we can require it. This is all too complicated and unnecessary. Simply mark Field B Required "No." This will change the content report to show the entire URL. Below is an example of the difference.
Before implementing the filter: After implementing the filter:
You will be able to see the full URL for all sub-domains. This will allow you search for sub-domain pages easily. This setup cannot be retroactively implemented. You can’t go back and have the URL added to all of your previous data. You will be starting fresh.
Your timing to implement this setup should probably be the start of the month. Otherwise, you will be adding new pageviews to your stats and not have an accurate picture of your analytics.
Step 3: Setting up goals
You will have to update your goal tracking to reflect the modified URL. The easiest way to do this is to use Regular Expression Matching. By selecting Regular Expression Match you can put in a portion of the URL that needs to match. EpikOne has a great tutorial on setting up goals with Regular Expressions.
If you are tracking an e-commerce site, this method can be difficult to implement. Consider a Google Authorized Analytics Consulting Company to help you implement tracking. Also, make sure that if any of your sub-domains have SSL encryption anywhere, you change your tracking script to be SSL compatible.