1

My old ga.js code is:

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

after I upgrade to new analytics.js code like this:

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-XXXXXX-1', 'auto');
ga('send', 'pageview');

I notice that my pageview is decreasing about 30% ~ 50%, and bounce rate is increasing about 130%

the obvious difference syntax between old and new is:

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

As far as I know, actually there is no sub domain site, I guess maybe the old analytics data is incorrect, and the new analytics data is correct.

Is there anyone can explain why the analytics data change so big or what am I doing wrong?

2

Make sure if you are upgrading from the ga.js to analytics.js that you add your domain to the Property's Referral Exclusion List. It is done by default for new properties but needs to be done manually for GA Properties that existed prior to the Google changeover to analytics.js

With analytics.js a change in source during a session will end the current user session and start a new one. Self referrals may be a reason for some of the issues you are seeing.

If there were any virtual pageviews tracked with ga.js then they will need to be ported over to the analytics.js syntax to continue tracking.

eta, there is also an upgrade guide available in the dev docs, in the event you need to also upgrade event tracking, custom variables and so forth https://developers.google.com/analytics/devguides/collection/upgrade/reference/gajs-analyticsjs

  • 1
    I'd check if any virtual pageviews have not been ported over. This would account for a drop in the pageview numbers. Only other things i can think of..ensure the code isnt missing on any pages Make sure no pages have a copy of each version of tracking (it will prevent it from tracking on the applicable page) Is it possible any of the pages were previously tagged incorrectly with double tracking code on them - lowering bounce rate and inflating the pageview count? – Bronwyn V Oct 6 '17 at 12:13
  • hi Bronwyn V, after I googled, some said check the network in the Chrome debug tool, if I see multiple "__utm.gif?....." requests, it means the page has incorrect multiple trackPageview, so I try this with my "old" ga syntax, it really shows "__utm.gif?....." twice as the screenshot image below, ibb.co/dkDF3w does this mean that my old ga data is "incorrect", and my new ga data is "correct"? – kRed Oct 11 '17 at 1:28
  • No, that is expected behaviour. It's initiated once by ga.js and once by _utm.gif. If you were seeing that x 2 on page load, then that would have been an issue. – Bronwyn V Oct 15 '17 at 5:58
  • thank you Bronwyn V, though I still can't find the real reason. :p – kRed Oct 17 '17 at 2:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.