: Upgraded one page of a site to the async Google Analytics - Data is now messed up I've upgraded one primary page of a site to use the async version of the GA tracking code. Since the upgrade,
I've upgraded one primary page of a site to use the async version of the GA tracking code. Since the upgrade, number of visits has increased by 60%, avg. time on site has decreased by 40% and the bounce rate of the said page is now always zero. Pageviews are intact.
I suspect this has to do with using both the traditional and async snippets on the same profile.
Other than that, it's a pretty standard setup. Right before </body>*, I have this:
var _gaq = [['_setAccount', 'UA-XXXXXX-XX'], ['_trackPageview'], ['_setDomainName', 'domain.com'], ['_setAllowLinker', true], ['_setAllowHash', false], ['_setAllowAnchor', true]];
(function (d, t) {
var g = d.createElement(t), s = d.getElementsByTagName(t)[0]; g.async = 1;
g.src = ('https:' == location.protocol ? '//ssl' : '//www') + '.google-analytics.com/ga.js';
s.parentNode.insertBefore(g, s)
} (document, 'script'));
Any other ideas, confirmations and suggestions?
*I know, it should go before </head>, will fix that in a new version.
More posts by @Speyer207
3 Comments
Sorted by latest first Latest Oldest Best
I had exactly the same problem when I added the async code to a site, it turns out I'd forgotten to remove the old code, so I had both the new and old code on every page. This was effectively recording two visits for every visitor, hence the traffic spike and the 0% bounce. I'd imagine you would have spotted that before posting here - but just in case, it might be worth another look at your page source.
Yes, _setAccount has to be first (to define which account you send the data to) and _trackPageView or _trackEvent have to be last otherwise subsequent commands will not affect the request.
Also on a side-note AFAIK, the correct syntax is :
var _gaq = (['_setAccount', 'UA-XXXXXX-XX'], ['_trackPageview']);
with parentheses not
var _gaq = [['_setAccount', 'UA-XXXXXX-XX'], ['_trackPageview']];
with square brackets,
although your syntax seems to be working too (otherwise PageViews would not be counted at all).
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.