Google Analytics... pretty easy question about tracking subdomains
This is barely even a question, I'd just like someone to confirm this for me! :)
Google Analytics has generated my tracking code for the subdomain sub.mysite.com. A line of the tracking code looks like this:
_gaq.push(['开发者_如何转开发_setDomainName', '.mysite.com']);
Do I need to change .mysite.com
to sub.mysite.com
? The tracking code page auto generates instructions for cases like these, but it mentions nothing about actually configuring it. I mean, does it detect the subdomain automatically, or am I being thick?
Cheers!
Jack
_gaq.push(['_setDomainName', '.mysite.com']);
(note the .
before mysite.com
) causes the tracking to take place on all subdomains of mysite.com
. See the documentation for _setDomainName
in the Google Analytics Tracker API.
If you only want to enable tracking for sub.mysite.com
, you can just use this instead:
_gaq.push(['_setDomainName', 'sub.mysite.com']);
P.S. You might also be interested in my post on optimizing the asynchronous Google Analytics snippet in terms of byte size and performance.
精彩评论