Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>When ran through your script <code>_gaq</code> is jut a regular Array. And just like any Array in JavaScript it has the method <code>push</code> that inserts one or more elements into the Array and returns the final length of the array.</p> <p>eg:</p> <pre><code>var _gaq = []; &gt; undefined _gaq.push(['_setAccount', 'UA-XXXXX-X']); &gt; 1 _gaq.push(['_setDomainName', 'mysite.com']); &gt; 2 _gaq.push(['_trackPageview'], ['_trackEvent', 'cat', 'act']); &gt; 4 </code></pre> <p>After the ga.js file is loaded the <code>_gaq</code> Array is read so the instructions pushed into it can be processed and then the <code>_gaq</code> Array is replaced with an object. The object implements the push function as well. But notice that in this case the push function will execute an instruction into the ga.js library and then return 0.</p> <p>eg:</p> <pre><code>var _gaq = { push: function(){ // Do something here return 0; } }; &gt; undefined _gaq.push(['_trackPageview']) &gt; 0 </code></pre> <p>That's a very smart Google design to create an API that can be used even before the library (ga.js) has been loaded. </p> <p>That's why during your script <code>_gaq.push</code> is a method of the Array class and return increasing numbers and on the console it always returns 0.</p> <p>This is not a problem at all. It seems to be working as intended.</p> <p><strong>UPDATE</strong></p> <p>It seems that ga.js is already loaded. Maybe it was cached and not showing on the network panel.</p> <p>ga.js is loaded by this part of the tracking script:</p> <pre><code> (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); })(); </code></pre> <p>It is loaded asynchronously. So after this snippet is executed it will be loaded but the exact point where it is loaded is unknown.</p> <p>If you need to know when the ga.js file is loaded, you can push a callback into _gaq and it will be executed when the ga.js file is loaded.</p> <p>eg:</p> <pre><code>_gaq.push(function(){ console.log('ga.js loaded!'); debugger; }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload