Here’s a fast and easy way to implement GA’s event tracking on your website using jQuery:
First thing we need to do is set the “rel” and “rev” attributes of the anchor tags where we we’ll implement event tracking. In this example we’ll use rel as the Category and rev as the Label (see Event Tracking guide for details about its parameters):
<a rel=”ExternalLink” rev=”WebscpeterBlog” href=”http://webscepter.com/a-simple-jquery-implementation-of-event-tracking-in-google-analytics”>easy event tracking</a>
We need to create the jQuery function that will track the click events. In this case, all anchor tag clicks are being tracked.
// the action parameter in this example is the current page url, you can change it according to your preference.
pageTracker._trackEvent(/*category*/$(this).attr("rel"), /*action*/ location.href, /*label*/, $(this).attr("rev"));
So that’s it. Simple, right? Please don’t forget your jQuery library as well as your Google Analytics code, well obviously.