How to track clicks on a banner

Discussion in 'Google Analytics' started by sylvestrerato, Jul 14, 2013.

  1. #1
    I would like to track the number of clicks on a banner leading to an external website. I implemented the code given on my Analytics page but it does not work. Here is the code for the banner:
    onClick="_gaq.push(['_trackEvent', 'External', 'Click', 'Banner']);" href="MyExternalLink" title="MyText" target="_blank"><img class="imageBorder" src="images/image.jpg" alt="MyAltText" width="468" height="60" /></a>
    Code (markup):
    I copied he code in the head section:

    <script type="text/javascript">
          var _gaq = _gaq || [];
          _gaq.push(['_setAccount', 'UA-1234567-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);
          })();
        </script>
    Code (markup):

    On my Analytics page, in the Content, Events section, nothing appears, even after 24h. What's wrong?

    Thank you for your time.
    Cheers
     
    sylvestrerato, Jul 14, 2013 IP
  2. sylvestrerato

    sylvestrerato Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #2
    Please disregard my post, I've found the problem. My code is right, it was my mistake. Sorry.
     
    sylvestrerato, Jul 14, 2013 IP