I've added the folowing code into my JS to track a button click:
_gaq.push(['_trackEvent', 'category', 'action', 'label']);
I've hit a breakpoint on it using teh Chrome dev tools and _gaq definitely resolves to the GA object and I can even step into the (minified) push event in the GA.js code. However, even though this fires with no errors, I dont see any GET or POST logged in Fiddler/firebug/Chrome, nor is anything logged on my analytics. Normal page analytics are working fine for me, with the followin running at the foot of the page:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'XXXXXXXXX']);
_gaq.push(['_setDomainName', '.Domain.com']);
_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);
})();
</script>
Anyone have any ideas why the above code isn't working?
A common cause are wrong parameter types (GA fails silently in this case).
For _trackEvent, parameters have to be:
string
string
string
integer
Don't use integers when a string is expected or vice versa.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With