The Docs pages are a little behind, because there were some recent changes that changed the best way to do it.
The default settings for _setDomainName
is 'auto'
. This will set the cookie to your full domain, unless you're on the www domain, in that case it sets to the mysite.com
without the leading dot. This settings can cause problems, and I avoid sticking with them. I allways change it
There are 2 options of setting a domain name for www.mysite.com
.
_setDomainName('.mysite.com')
-> This is necessary when you want to track all the subdomains as well.
_setDomainName('www.mysite.com')
-> You should use this one if you don't want to track your subdomains.
In 99% of the cases I go with the first option. Setting it for the top domain but using the leading dot.
You'll see a lot of people advocating against the leading dot. Like this old but good post from roirevolution. The concerns around the leading dot is that it can cause cookie resets. But it only happens if someone already have the cookie. If this is anew implementation you don't have this problem.
_setDomainName('none')
is equivalent to _setDomainName('auto')
+ _setAllowHash(false)
. But since _setAllowHash(false)
was deprecated I guess _setDomainName('none')
should be deprecated as well.