Pin It

blindfolded subdomainTo 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…

  1. Cross-domain tracking
  2. 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:

www.example-testsite.com

newyork.example-testsite.com

california.example-testsite.com

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.

Asynchronous syntax

var _gaq = _gaq || [];

_gaq.push(['_setAccount', 'UA-12345-1']);

_gaq.push(['_setDomainName', '.example-testsite.com']);

_gaq.push(['_trackPageview']);

Traditional (ga.js) syntax

var pageTracker = _gat._getTracker(“UA-12345-1″);

pageTracker._setDomainName(“example-adultsite.com”);

pageTracker._trackPageview();

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 I’ve set it up in the past.

Step 2. Modifying a Cross-Domain Profile With Filters

With out 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.

  1. Go to the settings page of the profile and select Add Filter.subdomain set up
  2. Select Add New Filter and give it a relevant name.
  3. Select Custom Filter and select Advanced on the Filter type settings.
  4. Under Advanced settings: FieldA should be set to Hostname and FieldB should be set to Request URI.
  5. Set the values for both Field A and Field B to (.*), which is an expression that captures all characters.
  6. 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 deeper insight on how traffic navigates through the different suddomains 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.

VN:F [1.9.22_1171]
Rating: 10.0/10 (1 vote cast)
Tracking Multiple Domains and/or Subdomains in Google Analytics, 10.0 out of 10 based on 1 rating