Search code examples
analyticstrackingsubdomain

Exclude subdomains from analytics tracking


I have a website on www.example.com and use Google Analytics. This website has lots of subdomains which I want to track using Google Analytics. It also has some static subdomains like static.example.com which serve all static content.

Google Analytics is issuing cookies on all subdomains but I don't want the static content traffic to be carrying the weight the GA cookies.

Any ideia on how to exclude the static subdomains from being tracked by Google Analytics?


Solution

  • You can use this line of code

    pageTracker._setDomainName("www.example.com")
    

    This will issue cookies for the www.example.com and the cookies won't be leaked to the static subdomain.