简体   繁体   中英

Updating Google Analytics code to link sessions between my domain and subdomain

I have my main site (www.site.com) that directs people to sign up for a service over on a subdomain (sub.site.com). When people sign up at the subdomain, I didn't want to see my own site as a referrer (which is what was happening), so after researching on GA's pages, I've updated my code so that _setAllowLinker is true. My understanding is this will link everything as one session so that I don't see myself as my own referrer. However, I'm still seeing that. Am I missing an additional piece of code? I'm using this piece of code for my domain and subdomain.

var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-xxx-1']);
  _gaq.push(['_setDomainName', '.site.com']);
  _gaq.push(['_setAllowLinker', true]);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

You say you have your _setDomainName as '.site.com'. Check if the other subdomain is using the tracking code at 'site.com'.

If so, then google analytics will interpret those as two different cookies, and you should make them the same. 'site.com' would be prefered. Check out Caleb Whitmore(cw)'s answer halfway down this discussion: http://productforums.google.com/forum/#!topic/analytics/PoYORgW1yOw

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM