O'Reilly logo

Google Analytics by Justin Cutroni

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Tracking Across Multiple Subdomains

Like tracking across multiple domains, the primary issue with tracking across multiple subdomains has to do with the cookie domain.

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.

Table 10-1. How subdomains affect cookie domains

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.

Table 10-2. Changing the cookie domain enables tracking across different subdomains

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required