Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have my web site at, and i have also setup a sub domain for serving static content at
On my web pages I'm using Google Analytics, so it will attach its cookies to all page request, even on

I went into the GA settings and added a filter to exclude, but I still see cookies (with the __utma.. name) on all web requests to my static domain.

How can i prohibit GA to use cookies on my sub domain?

share|improve this question
Why do you not want the cookies to be there? Does it matter as long as the content isn't being tracked? – John Conde Sep 6 '10 at 13:57
Google's speed test gives you a ++ if you are serving static content from a cookieless domain. Google gives, google takes. – Thomas Sep 6 '10 at 14:32
Interesting.... – John Conde Sep 6 '10 at 15:17
@thomas +1 for seeing the reason this question was asked. – Talvi Watia Sep 6 '10 at 22:29
Why does it matter what Google's speed test gives you? Isn't that just a performance testing tool for webmasters? Unless you want to delude yourself with a non-existent performance improvement, there's no point in removing cookies just to game a speed test that is only meant for you. – Lèse majesté Sep 9 '10 at 10:32

4 Answers 4

up vote 3 down vote accepted

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

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

As is not a subdomain of (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 that wouldn't help your other users who would not have access to this information.

share|improve this answer
Thanks, I was afraid of that. I will be using a dedicated for my static content. – Magnus Sep 10 '10 at 18:41
You don't need another domain. donaldthe just suggested a valid method. – machineaddict Nov 28 '13 at 15:47

Like this (with the new GA code)

_gaq.push( ['_setAccount', 'UA-xxxxx-x'], ['_setDomainName', ''], ['_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.

share|improve this answer
Thanks! This variable showed me the light. The current code is _gaq.push(['_setDomainName', '']);, put it after the _gaq.push(['_setAccount', 'UA-12345-1']); directive in the js code. See also… – ArendE Feb 7 '14 at 23:30

Like Kris said, any cookies set on will be available on 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

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

share|improve this answer
StackOverflow uses because it delivers the static content to multiple websites. On a single website there is no need in getting a new domain. I'm using the same setup (with subdomain) and never had problems with cookies. They are not sent to subdomains. – machineaddict Nov 28 '13 at 15:50
@machineaddict not true: you probably set cookies on the www subdomain and not the root domain. – DisgruntledGoat Nov 28 '13 at 17:54

The correct(est) answer is _gaq.push(['_setDomainName', 'none']); (

In my tests, explicitly setting a domain WITHOUT a sub-domain (e.g., instead of still resulting in cookies being sent to Setting the domain name to 'none' solved this.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.