When you went through the script _gaq , this is a regular Array. And like any array in JavaScript, it has a push method that inserts one or more elements into the array and returns the final length of the array.
eg:
var _gaq = []; > undefined _gaq.push(['_setAccount', 'UA-XXXXX-X']); > 1 _gaq.push(['_setDomainName', 'mysite.com']); > 2 _gaq.push(['_trackPageview'], ['_trackEvent', 'cat', 'act']); > 4
After loading the ga.js file, the _gaq array _gaq read, so the instructions inserted into it can be processed, and then the _gaq array _gaq replaced by the object. The object also implements the push function. But note that in this case, the push function will execute the instruction in the ga.js library, and then return 0.
eg:
var _gaq = { push: function(){
This is a very smart Google design for creating an API that can be used even before loading the library (ga.js).
That's why during your script _gaq.push there is an Array class method and returns increasing numbers, and on the console it always returns 0.
It's not a problem. It seems to be working as intended.
UPDATE
It seems that ga.js is already loaded. It may have been cached and does not appear on the network panel.
ga.js is loaded with this part of the tracking script:
(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); })();
Loads asynchronously. Thus, after executing this fragment, it will be loaded, but the exact point of its loading is unknown.
If you need to know when the ga.js file is uploaded, you can push the callback on _gaq and it will be executed when the ga.js file is uploaded.
eg:
_gaq.push(function(){ console.log('ga.js loaded!'); debugger; });