Google Analytics event works in Developer Console but not in page <p>I have this code in my product page after an item has been added to cart:</p> <pre><code>&lt;script type="text/javascript&gt; //&lt;![CDATA[ (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'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga); })(); var _gaq = _gaq || []; _gaq.push(['_setCustomVar', 1, 'Page Type', 'Product', 3]) _gaq.push(['_setCustomVar', 2, 'Product Name', 'Gold Bracelet', 3]); _gaq.push(['_trackEvent', 'Product Page', 'Added To Basket', 'Gold Bracelet', , 0]); // this is the line that isn't working. _gaq.push(['_setAccount', 'UA-XXXXXXX-1']); _gaq.push(['_trackPageview']); //]]&gt; &lt;/script&gt; </code></pre> <p>It seems the pageview is tracked, the two custom variables, but not the _trackEvent. Like I said in the title, if I copy and paste this code into Chrome Dev Console, the events show up just fine. I added an alert() to the code that returns the _trackPageview and it worked, so the JS is definitely getting parsed.</p> <p>Any idea what i'm doing wrong?</p> <p>Thank you</p>