Subdomain tracking in Google Analytics can be done by modifying your tracking code. Instead of the default, it should be modified to the following (only changed parts are included, the rest should remain the same):
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'YourProfileID']);
_gaq.push(['_setDomainName', 'ExampleDomain.com']);
_gaq.push(['_addIgnoredRef', 'ExampleDomain.com']);
_gaq.push(['_trackPageview']);
Replace YourProfileID with your Google Analytics profile identifier, and ExampleDomain.com with your domain.
A filter will also need to be added to the profile in order to display the domain and subdomain names. To do this, follow these instructions from Google:
- In the Profile Settings page, click the Add Filter link.
- Choose Add New Filter and provide the filter a name.
- Choose Custom Filter and select Advanced on the Filter type settings.
- Under Advanced settings:
- FieldA should be set to Hostname
- 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.