Tracking events with Google Analytics

So, we had some hyperlinked images on one of our websites, each leading to the same page, but with a different $_GET which identifies which button this was. As far as my knowledge goes, that would have made the page duplicate (in google robot’s eyes), which then would have a minor impact on the organic page rankings.

And because organic page ranking is quite important, I thought I’d do some digging regarding to tracking hyperlinks with Google Analytics. I found lots of information regarding to tracking form buttons, flash files and allsorts but most were crowded with extra information.

The line of code that tracks this event is quite simple, and all you need to do is add it into your <a> or your <input type=’button’>

onClick=”pageTracker._trackEvent(category, action, optional_label, optional_value)”

Category in this case was the general name for the event which happened to be ‘Buttons’.
Action in this case was what they’d done, so I named it ‘Click’.
Optional_Label in this case wa a numerical indicator dependant on which button was clicked.
Optional Value I didn’t acually use, as I didn’t see any point in assigning the button a value, as each was equal as each other.

It should look something like this:
<a onclick="pageTracker._trackEvent('buttons'," href="/page.htm">Link text here</a>

Sorted! Just log into your Google Analytics account, go to the website report -> Content -> Event Tracking and within a few days you’ll see some numbers 🙂

Need a hand? Just post a comment!


Posted

in

by

Comments

One response to “Tracking events with Google Analytics”

  1. Hi mate,
    I’ve been adding these to various links, this docuementation has been useful.
    Cheers,
    Damien

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.