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.


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


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.

  • Nice catch! Forgot to mention this, but yeah, a consultant has also recommended to put _trackPageview at the end - Did that and I'll let you know of the effect after uploading the next version.
    – Ronny
    May 5 '11 at 12:06
  • Thanks again Ewan and everyone else who noticed the commands order - The new version is up now, and this worked :-)
    – Ronny
    May 31 '11 at 6:14

I would agree with what Ewan is saying, _trackPageview has to be the last of the arguments you call because the first arguments are rewriting the arguments or values that _trackPageview then sends to Google (or they are just adding arguments). So the additional or altered arguments need to be defined before you send them over to Google, otherwise you change them after they have already been sent and Google doesn't get noticed about it.


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.

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.