: Does Google Analytics subdomain tracking need to be set up on every subdomain simultaneously? I'm cleaning up the Google Analytics tracking for a complex corporate website. The website is spread
I'm cleaning up the Google Analytics tracking for a complex corporate website.
The website is spread across a bunch of subdomains (www.example.com for the main content, dev.example.com for developer information, pages.example.com for legacy content, and so on) and I've found that each subdomain uses its own tracking cookie, so Analytics treats them all as separate sites (when tracking referrals, for example) even though the data all feeds into the same web property.
As Google recommends, I'm going to fix this by adding _gaq.push(['_setDomainName', 'example.com']); to the tracking code on each subdomain, so that they all use the same tracking cookie. However, the site is very complex and several different groups maintain their own subdomains, so it's going to be difficult to coordinate the switchover.
In particular, this comment gives me pause:
Yes you have to use setDomainName(".mydomain.com") on all www pages as well. Otherwise cookies might get overwritten everytime you change subdomains and data loss will occur.
So, given that:
the bare domain (example.com) just redirects to the www subdomain, and
some of the subdomains currently have the _setDomainName method explicitly set to 'none', but some don't have it set at all,
do we risk any data corruption if we stagger the tracking code update across the subdomains?
More posts by @Harper822
1 Comments
Sorted by latest first Latest Oldest Best
This relates to how cookies are shared across sub-domains. A cookie set on your main site with the domain example.com can't be accessed by pages.example.com, however a cookie set with the domain example.com can be accessed by both. It doesn't matter that example.com just redirects to your main site, your main site can still use example.com as the domain with cookies that it sets (as example.com is a subdomain of example.com). Sounds more complicated than it is!
So, I'd suggest:
Modify the tracking code on your main domain first (to add the _gaq.push(['_setDomainName', 'example.com']);
Then modify your sub-domains as and when you can
If you don't do this, then someone who arrives at example.com and then clicked on a link to pages.example.com would be registered as two visitors, because Google Analytics wouldn't be able to track that they're the same person. So that's what the comment means by "data corruption".
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.