Mobile app version of vmapp.org
Login or Join
Speyer207

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

@Speyer207

Posted in: #GoogleAnalytics

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.

10.04% popularity Vote Up Vote Down


Login to follow query

More posts by @Speyer207

3 Comments

Sorted by latest first Latest Oldest Best

 

@Rambettina238

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.

10% popularity Vote Up Vote Down


 

@Steve110

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

10% popularity Vote Up Vote Down


 

@Becky754

I notice that your calling _trackPageview before _setDomainName. That could cause some problems with the cookies. Try putting _trackPageview at the end of the command list and see if it solves the problem.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme