This is how the cookie domain is usually set in Google Analytics's tracking code. I understand auto and none are the other two options.
ga('create', 'UA-45015643-1', 'example.com');
The above code, which is a part of Universal Tracking code, sets the cookie domain to .example.com.

Setting cookie domain to .example.com makes cookie accessible to all of its subdomains. But I have set up a cookie-free domain http://static.example.com to download static contents and I don't want cookies to be sent along with this type of static resource request. So, I tried this:
ga('create', 'UA-45015643-1', 'www.example.com');
This resulted the cookie domain to be set to .www.example.com. The tracking was working fine after this update (I used Realtime view to verify), apparently.
But I want to be sure if this actually have no side effects or is not a bad practice.
GA recommends you set the cookie to the TLD (example.com) so that if you go from let's say www.example.com to cart.example.com or secure.example.com in the checkout process, your visitors would still share the main example.com cookie.
If this isn't a concern for you, then you can use the www.example.com configuration above without consequence.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With