Dec 01, 2010

Configure 'Google Analytics for WordPress' plugin for Subdomain tracking

Yesterday, I created a sub-domain in my site. To configure Google analytics to track content and visitor data for sub-domain, I searched and found following in Google code:

a default setup of Google Analytics is designed to track content and visitor data for a single domain, such as This means that even if you manage both a domain and a sub-domain, you must make modifications to the tracking code in order to share visitor data across both domains.

Suppose you have the following URLs that you want to track as a single entity:

For this setup, you would use the following key customizations for the tracking code on all three domains.

Asynchronous syntax

//Tracking code customizations only
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-12345-1']);
  _gaq.push(['_setDomainName', '']);
  _gaq.push(['_setAllowHash', false]);

Traditional (ga.js) syntax

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

You will not have to make any adjustments to the links or forms between these three sites, since they can all share the same cookies due to the fact that you set the domain name to the top-level domain (e.g.,

I use Google Analytics for WordPress plugin. To configure for subdomain, In admin section > Go to settings > Google Analytics

In Domain Tracking Option, Enter your domain Name.


Click "Update Google Analytics Settings" Button.

Now you will get tracking report of sub-domain. See How To See Subdomain Tracking Report In Google Analytics also.

Hope, It helps.