performancecookiesgoogle-analyticssubdomaincookieless

Google Analytics vanishes my effort to make a cookieless domain


I setup the subdomain static.map.ninux.org to load static files for the domain map.ninux.org. The goal was to have a cookieless domain.

I checked and I found out that google analytics on map.ninux.org creates cookies with the domain ".map.ninux.org" that for some reason are valid also for static.map.ninux.org.

How can I solve this issue?

PS: is this code correct?

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-26436344-1']);
_gaq.push(['_trackPageview']);
_gaq.push(['_setDomainName', 'map.ninux.org']);
(function () {
    var ga = document.createElement('script');
    ga.type = 'text/javascript';
    ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(ga, s);
})();

With this I still get the cookies with host ".map.ninux.org"


Solution

  • Edit:

    You can't make static.map.ninux.org cookie free when setting a cookie for map.ninux.org, because static.map.ninux.org will inherit all cookies from map.ninux.org (and you don't have any chance to change this behaviour).

    You may want to change the cookiefree domain name to static-map.ninux.org instead. In this case the default setting of _setDomainName which is 'auto' will work correct.