Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Analytics Domain With and Without WWW

If I store a cookie or set a session associated with http://mydomain.com, the same cookie or session will not be picked up on http://www.mydomain.com. I am putting down http://mydomain.com as my default URL.

Will Google Analytics track both the www and non-www domains as one in this case?

like image 531
Lloyd Banks Avatar asked Nov 13 '13 19:11

Lloyd Banks


1 Answers

If you set your own cookie with a domain of "mydomain.com", then it will only be visible on that domain (no subdomains). If you set your own cookie as ".mydomain.com" (prefix it with a dot), then it will be visible "mydomain.com" and any subdomain of mydomain.com.

GA by default sets its cookie on the exact domain, so if you are on "www.mydomain.com" then it will set it for "www.mydomain.com" and it will not be visible on "mydomain.com" or some other subdomain. If however you specify to GA to use "mydomain.com" then it will be available on any subdomain. Note the lack of dot, which is not consistent with how you would normally set a cookie domain with your own code. This is because GA automatically prefixes a dot to it, within their own code.

For more info, refer to their document entry on Tracking Multiple Domains

like image 119
Crayon Violent Avatar answered Oct 02 '22 09:10

Crayon Violent