By default, the GATC includes the website subdomain in the cookie domain. This means that a cookie set by the GATC while the visitor is visiting one subdomain cannot be utilized by the GATC on a different subdomain. So, a visitor who visits multiple subdomains on a website will receive a different set of tracking cookies for each subdomain. Table 10-1 includes some examples that illustrate this issue.
| Domain | Cookie domain | Can be accessed by |
| support.website.com | .support.website.com | support.website.com only |
| secure.website.com | .secure.website.com | secure.website.com only |
To resolve this issue, the cookie domain must be consistent from one subdomain to another. This means removing the subdomain from the cookie domain. Once you have removed the subdomain, the GATC can access the cookie that appears on any subdomain, as shown in Table 10-2.
| Domain | Cookie domain | Can be accessed by |
| support.website.com | .website.com | support.website.com or secure.website.com |
| secure.website.com | .website.com | support.website.com or secure.website.com |
You can change the tracking cookie domain using the _setDomainName() method. _setDomainName() is not used in the default configuration; this is what causes the inclusion of the subdomain in the cookie domain.
Implementation
You can configure Google Analytics to track visitors across multiple subdomains with the following process:
- Modify the tracking code to include the _setDomainName() method.
- Apply a filter to clarify Google Analytics reports.
- Segment traffic into multiple profiles for improved reporting (this step is optional but recommended).
Begin by modifying the GATC to include the _setDomainName() method. You can pass _setDomainName() a specific value, which will in turn be used for the cookie domain. So, using _setDomainName() to force the cookies to use the website’s primary domain lets the tracking code access the cookies on various subdomains.
Add the primary domain of the website to the setDomainName().Pass method (be sure to include a leading period):
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXX-YY']);
_gaq.push(['_setDomainName', '.cutroni.com']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript';
ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl'
: 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
</script>No need to do this manually: you can use the tracking code configuration tool, as shown in Figure 10-4.
Once you have modified and installed the tracking code, add a filter to the appropriate profile (Figure 10-5). The filter will differentiate pages that appear on multiple subdomains. For example, the page index.html may appear on multiple subdomains but will appear as index.html in the reports. Adding the hostname to the request URI will differentiate multiple versions of the same page.

The final step in configuring multiple subdomains is optional but recommended. It is a good idea to create a separate profile for each subdomain. This provides a greater level of reporting and more insight into visitor actions on each subdomain.
Warning: This filter, or any filter that modifies the Request URI field, will break the Site Overlay report. The reason is that the Site Overlay report uses the request URI to identify which links in the Site Overlay report correspond to specific data (like clicks and visits).
To create the subdomain-specific profiles, use an include filter (Figure 10-6) based on the Hostname field. When complete, there should be one main profile that contains summary data for all subdomains and individual profiles for each subdomain.

Learn more about this topic from Google Analytics.
Take advantage of Google Analytics' powerful and free tools to understand exactly how users behave when they visit your website or use your web application. This hands-on guide shows you how to probe general traffic, marketing, and ecommerce information with these tools, and teaches you how to supplement them with add-ons and external tools when you want to dig even deeper. You'll also learn how to create custom reports to analyze specific issues.

Help


