How can I tell Google Analytics to not use cookies for my sub domain?

Like this (with the new GA code)

_gaq.push(
    ['_setAccount', 'UA-xxxxx-x'],
    ['_setDomainName', 'www.example.com'],
    ['_trackPageview']
);

It still won't block other 3rd party apps you may be using from setting cookies to your static subdomain but at least you are getting rid of the GA cookies which are quite large.


You can not do this. Any cookie issue for domain example.com is valid for all subdomains of example.com.

If you wish to have static.example.com be a cookie free domain, you should serve up the main site at www.example.com (you can provide a 301 redirect from example.com to www.example.com).

As static.example.com is not a subdomain of www.example.com (rather a sibling), it will not share its cookies.

This doesn't really have anything to do with Google Analytics, this is simply how the WWW works. Even if you could tell GA to not send the cookies to static.example.com that wouldn't help your other users who would not have access to this information.


Like Kris said, any cookies set on example.com will be available on static.example.com and other subdomains. If you want to keep the site without the www. then I'd suggest using a different domain name (for example, Stack Overflow uses http://sstatic.net).

If you have multiple domains already, for example yourbusiness.net redirecting to yourbusiness.com then you can simply use the .net one to host all the static content.