views:

25

answers:

1

To optimize my site i have set up a static subdomain for content such as images, css and javascript. How do i stop the google analytics tracking cookie from being sent to my static subdomain, but still to both example.com and www.example.com?

Have already looked through some of the documentation with no luck

+2  A: 

You can't have a cookie that gets sent to www.example.com and example.com but not othersubdomain.example.com.

You can in theory have a cookie that gets sent to example.com but not subdomain.example.com, but it doesn't work in IE.

This is why you should not use a no-www example.com address when you are planning on using subdomains with their own security context. It's best to have only one of www.example.com and example.com as the ‘proper’ URL anyway. So set up a redirect for example.com to go to www.example.com, and cookies won't be shared unless you deliberately set domain=.example.com on them.

bobince
fantastic thank you
Olly Hicks
for anyone interested the code for the redirect was RewriteEngine on RewriteCond %{HTTP_HOST} ^example\.com RewriteRule ^(.*)$ http://www.example.com/$1 [R=permanent,L]and then in the google analytics script you need to put _gaq.push(['_setDomainName', "www.example.com"]);
Olly Hicks