Dot or Not


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(‘’).

John is a former LunaMetrician and contributor to our blog.

  • Hi Robbin,
    this is a really good post !
    Indeed this is a reccurent question, and you make it clear !
    Really love the title of the post too 😉

  • PS /
    I will repost in my french blog,
    hope it will be ok for you,
    if not let me know.

  • Really good article. Always been wondering where to use the leading dot, when tracking cross several sub domains.

    This helped – Thanks 🙂

Contact Us.

Follow Us



We'll get back to you
in ONE business day.
Our Locations
THE FOUNDRY [map] LunaMetrics

24 S. 18th Street
Suite 100

Pittsburgh, PA 15203


4115 N. Ravenswood
Suite 101
Chicago, IL 60613


2100 Manchester Rd.
Building C, Suite 1750
Wheaton, IL 60187