h5bp/html5-boilerplate — Issue #987: GA optimization causes UA-XXXXX-X to be sent as account number
Author: toneplex
Created: 2012-02-17 15:13:50+00:00
State: open

What's happening:
When making use of the _gaq optimization, by putting the setAccount and _trackPageView in initial _gaq array, GA will sometimes get the correct account number and sometimes get the default account number UA-XXXXX-X.

How to reproduce:
Install the GA chrome extension [https://chrome.google.com/webstore/detail/jnkmfdileelhofjcijamephohjechhna] or use CharlesProxy.
Then go to http://html5boilerplate.com/ and refresh a few times. You'll see that the UA number is a random mix of the correct number and the default account number.

How to fix:
By changing the _gaq back to the stand .push method the account number is correct on every page load.

So convert:

var _gaq=[['_setAccount','UA-17904194-1'],['_trackPageview']];

to:

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-17904194-1']);
_gaq.push(['_trackPageview']);