I have the asynchronous JavaScript from Google added to my HTMl page which adds the tracker:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
_gaq.push(['_trackPageview']);
(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);
})();
Then in an external JS file which is definitely loaded after ga.js I have the following:
function activateAnalyticsTracking(href) {
_gaq.push(['trackEvent', "test", "tester"]);
console.log("_gaq.push called");
}
Now my console outputs "_gaq.push called", and I don't have any other vars on the page called _gaq, so I don't understand why, when I use a HTTP logging tool like Fiddler2 I don't see a call made to Google-analytics.
I do see a call though when I simply run _gaq.push(['_trackEvent', "test", "tester"]) from the console, so the code for that call is definitely right.
I have this function used specifically because I run other events when I link is clicked, so I'd like to use it, can anyone help me understand why this wouldn't work?
TIA
Cheers,
Blaise.
console.log("_gaq.push called", _gaq);
– Eduardo