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 www.example.com. 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', '.example-petstore.com']); _gaq.push(['_setAllowHash', false]); _gaq.push(['_trackPageview']);
Traditional (ga.js) syntaxvar pageTracker = _gat._getTracker("UA-12345-1"); pageTracker._setDomainName(".example-petstore.com"); pageTracker._setAllowHash(false); pageTracker._trackPageview();
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., .example-petstore.com).
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.