Mobile app version of vmapp.org
Login or Join
Tiffany637

: How can I tell Google Analytics to not use cookies for my sub domain? I have my web site at example.com, and i have also setup a sub domain for serving static content at static.example.com.

@Tiffany637

Posted in: #Cookie #GoogleAnalytics #Subdomain

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

I went into the GA settings and added a filter to exclude static.example.com, 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?

10.04% popularity Vote Up Vote Down


Login to follow query

More posts by @Tiffany637

3 Comments

Sorted by latest first Latest Oldest Best

 

@Rivera981

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.

10% popularity Vote Up Vote Down


 

@Cofer257

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 then I'd suggest using a different domain name (for example, Stack Overflow uses 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.

10% popularity Vote Up Vote Down


 

@Angela700

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 example.com (you can provide a 301 redirect from example.com to example.com).
As static.example.com is not a subdomain of 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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme