views:

25

answers:

1

Hey folks,

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

+1  A: 

_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.

Mathias Bynens