Tracking Outgoing Links With Google Analytics Events

Posted by the_archer on Pro Webmasters See other posts from Pro Webmasters or by the_archer
Published on 2012-06-15T13:36:22Z Indexed on 2012/06/16 9:23 UTC
Read the original article Hit count: 259

Filed under:
|
|

I've been trying to track clicks on external links on my website using the events tracking method.

So I've got my Google Analytics code setup before body ends as shown below (note: quotes have been entitied by blogger, but it works fine):

<script type='text/javascript'>

          var _gaq = _gaq || [];
          _gaq.push([&#39;_setAccount&#39;, &#39;UA-XXXXXXX-X#39;]);
          _gaq.push([&#39;_trackPageview&#39;]);

          (function() {
            var ga = document.createElement(&#39;script&#39;); ga.type = &#39;text/javascript&#39;; ga.async = true;
            ga.src = (&#39;https:&#39; == document.location.protocol ? &#39;https://ssl&#39; : &#39;http://www&#39;) + &#39;.google-analytics.com/ga.js&#39;;
            var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(ga, s);
          })();

</script>

Now I wanted to track a link on the addthis.com follow widget. So there is a link of the type below to which following instructions from here I added the onclick event.

<a addthis:url='http://feeds.feedburner.com/myfeedburnerlurl' onClick="_gaq.push(['_trackEvent', 'Subscription Clicks', 'RSS']);" class='addthis_button_rss_follow'/>

I clicked on it a couple of times, left it for over a day now, but nothing shows up in google analytics events. It just says zero events. Here's a screenshot of the events page on GA:

GA events page

Could anybody help me? Am I doing anything wrong?

© Pro Webmasters or respective owner

Related posts about JavaScript

Related posts about html