referer within subdomains
I need to use google analytics on a domain that has many subdomains, but they should all be inside the main domain.
Like this:
my website: a.com subs: x.a.com, y.a.com, z.a.com he is coming from: google.comLets say the users starts at x.a.com, then he clicks something and goes to y.a.com, and finally, he ends up buying something a开发者_开发知识库t z.a.com.
I would like to know, if I will be able to know that he came from google, so we can mesure where to put our money on.thanks,
JonathanThe most important setting is to use the same setDomainName call and parameter value everywhere. Now, it depends on what you have today, and how important are you previous visitor cookies to you.
The recommended setting is:
_gaq.push(['_setDomainName', '.a.com']); // notice the point before a.com
on every single sites
However, if you didn't previously used setDomainName, you will erase cookies from your previous visitor and start with 100% of new visitors. But it is recommended for sub domains and sub-subdomains, like in your case. The alternative is to set instead :
_gaq.push(['_setDomainName', 'a.com']); // notice NO point before a.com
This way, you share campaign cookie (and all other GA cookies) within all a.com sites. And you'll get the source of their visit when landing anywhere on a.com sites.
Additionally, in case you want to ignore side effects of cross domain navigation after the visit has expired, you can remove referrals with this, before _trackPageview :
try{ if ( /\.a\.com/.exec(document.referrer) ) { _gaq.push(['_addIgnoredRef', document.referrer]); } } catch(e){}
精彩评论