google analytics returning visitors number drop after subdomain-tracking related tracking code modification

StackOverflow https://stackoverflow.com/questions/8471518

Вопрос

last friday we switched our website, www.ourweb.com tracking from "single domain" to "one domain to multiple sub-domains", to track both www.ourweb.com and blog.ourweb.com so i modified the code on the site:

<script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
  </script>
  <script type="text/javascript">
    var pageTracker = _gat._getTracker("UA-1594022-3");
    pageTracker._trackPageview();
</script>

to (note we used traditional snippet before):

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12345-1']);
_gaq.push(['_setDomainName', '.ourweb.com']);
_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);
  })();

but over last few days, site reported almost double returning visitors drop! from stable 7 000 down to 4 000

only returning visitors number changed that much, new visitors number keeps being similar (around 10 000)

i read this http://www.roirevolution.com/blog/2011/01/google_analytics_subdomain_tracking.php

and they write there that "The leading period causes cookie resets.". is that the reason of such big visitors drop? should i remove the leading period? and if not, what else could be the reason?

ps. i just noticed that probably it's referrals only problem. amount of visitors from referrals decreased from 4000 to around 700 per day after change.

Это было полезно?

Решение 2

visitors drop happened because there was no straight redirect between ourweb.com and www.ourweb.com

ourweb.com was displaying same site as www.ourweb.com, but with all links pointing to www.ourweb.com, and all 3000 return visits drop came from self referrals.

thus cookies were split between those two sites and created fake unique return visits (each time visitor visited ourweb.com and clicked f.ex. link to about.html, he was going to www.ourweb.com/about.html, so ga counted it as two independent unique return visits)

so basically reporting was wrong before and became more accurate.

Другие советы

This is a silly quirk of Google Analytics that should be better documented.

There are 2 equally valid but slightly sifferent methods for using _setDomainName.

No Leading Period:

_gaq.push(['_setDomainName', 'ourweb.com']);

Leading Period:

_gaq.push(['_setDomainName', '.ourweb.com']);

Google Analytics uses something called a "domain hash" (literally, a hash of the domain or of the domain you set in _setDomainName) to prevent conflicts between cookies; if the domain hash of the domain you've configured does not match the Google Analytics cookies that it finds, it creates a brand new visit (and a brand new visitor).

The difference is this: By default, if you don't configure your setDomainName, your root www domain gets a "domain hash" that is the same as if it is just http://ourweb.com. That's presumably to prevent self-referrals for traffic between www. and no www.

However, if you add the leading period, the "domain hash" changes. None of your returning visitors will have a matching domain hash. So, when they enter your site, Google Analytics doesn't see a matching set of cookies with the correct domain hash and creates a new visitor id, and all your traffic since the change is totally cut off from the traffic before the change.

As a result, if you have long-standing tracking without using _setDomainName, and you'd like to add support for tracking across subdomains, the way to do so with the last damage is to use no leading period.

You can "recover" the old cookies by switching to using no leading period. If you do so, you'll lose the cookies since you've made the change, though.

The only benefit in using the leading period is that it provides compatibility for third level subdomains (ie, foo.bar.example.com).

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top