Tracking Multiple Domains and/or Subdomains in Google Analytics
To Properly track the visitors of your site is the first and foremost critical step of collecting reconnaissance traffic data. Without it, you’re lost like a blind man in an orgy trying to feel things out. There are no clear instructions for installing Google Analytics to track multiple subdomains or two different domains in the same profile. Rather, there are several different ways to get the job done and the method you choose will greatly effect your reports and the ability to accurately monitor your traffic. To achieve the deepest crawling and render the most thorough report, I suggest the use of these two methods.
- Cross-domain tracking
- Filter modifications
Step 1. Cross-domain Tracking Across a Domain and Its Subdomains
The default settings for Google Analytics are to track one single domain at a time so if we want to track any subdomains of the top level domain we will need to modify the GA code snippet so it will show which subdomain the visitor entered the site from or if they navigate to other subdomains within the site. Luckily, all subdomains share the same cookies making this easier to implement.
I will use the examples below in my demonstration:
For this setup, you simply put a . in front of the domain to enable cookie access to any and all subdomains. If using the traditional GA code use the modification I used below.
var _gaq = _gaq || ;
Traditional (ga.js) syntax
var pageTracker = _gat._getTracker(UA-12345-1);
Again, no changes to the forms or links will be needed as they all share the same cookies as the top level domain. If you need a working example, you can look at the GA code in the header and the code in the links of TheLeadTree.com and LeadTree.org to see how Ive set it up in the past.
Step 2. Modifying a Cross-Domain Profile With Filters
Without this step, you will only be able to see the URI in your content reports and not the domain or subdomain. So if someone visits newyork.example-testsite.com/females, you will only see /females/ in the report with no indication of which page is for which domain. This is why we want to tell GA to show us the full URL and not just the last part of the URI. We do this by adding a filter.
- Go to the settings page of the profile and select Add Filter.
- Select Add New Filter and give it a relevant name.
- Select Custom Filter and select Advanced on the Filter type settings.
- Under Advanced settings: FieldA should be set to Hostname and FieldB should be set to Request URI.
- Set the values for both Field A and Field B to (.*), which is an expression that captures all characters.
- Set the Output To > Constructor option to Request URI and provide $A1$B1 as the value for that choice.
You will now have the most comprehensive reports that will give you a deeper insight on how traffic navigates through the different subdomains of your site!
SEO Karma: As always, don’t forget to show some Google love and like, tweet, plus or Digg this page if you found the information to be helpful.