开发者

referer within subdomains

开发者 https://www.devze.com 2023-03-10 04:23 出处:网络
I need to use google analytics on a domain that has many subdomains, but they should all be inside the main domain.

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

Lets 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,

Jonathan


The 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){}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号