Google Anlytics event not firing

Posted by yar1 on Stack Overflow See other posts from Stack Overflow or by yar1
Published on 2013-11-06T15:51:28Z Indexed on 2013/11/06 15:53 UTC
Read the original article Hit count: 129

Filed under:

I am not getting and event data in GA. I installed Google Analytics Debugger Chrome extension and I see nothing happening (same goes when looking at Network panel in developer tools). I Googled it and read many (many) other answers and it looks like I'm doing things right. Page views, etc. are registering correctly...

I have this code as the last thing before my closing tag:

<script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
        (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
    ga('create', 'UA-MYREALCODE', 'mybna.net');
    ga('send', 'pageview');
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-MYREALCODE']);
    _gaq.push(['_trackPageview']);
</script>

My event handlers are done using jQuery, all inside an external js file, loaded before the closing tag. For example:

$(function () {
    $('#show-less').click(function (e) {
        pbr.showHideMore(e);
        _gaq.push(['_trackEvent', 'ShowMore', 'Hide', 'top button']);
    });
});

Any ideas anyone?

© Stack Overflow or respective owner

Related posts about google-analytics