Dot Or Not

May 27, 2009

We often hear variations on the question “Do we need the leading dot when using _setDomainName”.

With the dot:

Without the dot:

The _setDomainName method is used to tell GA what to set the “domain” to, for the cookies that it uses to keep track of visitor information.  This “domain” field for the cookies are used as part of the security in browsers to determine what websites can access what cookies. (You don’t want getting access to your cookies, for example.)

The Google Analytics documentation recommends using a preceding dot.  For example: pageTracker._setDomainName(‘’)

The example above allows any subdomain to access the same cookies.  ( and are both still “” so the browser says this is okay)

In most cases, it doesn’t really matter whether you use ‘’ or ‘’.  As long as you’re consistent across the entire website that you’re tracking. That’s part of the confusion.  Both ways work fine.

However, Google explains, in cases with multiple levels of subdomains, you can sometimes run into problems if you don’t use the preceding dot with _setDomainName.  If we had the browser may not let the GA code on that page have access to cookies written with _setDomainName(‘’), but it would allow access to cookies written with _setDomainName(‘’).