Tracking link clicks with Google Analytics
When I released Skylights a few months ago, I wanted to track how many people actually clicked the download link to give me a rough idea of how many people were trying them out.
Luckily, Google Analytics lets you track particular interactions on your site using ‘Events’. Setting up an event to be logged is pretty straightforward, all you need to do is add a tiny bit of code to the onClick attribute of a link like so:
<a href=’download’ onClick=’_gaq.push([‘_trackEvent’, ‘Download Button’, ‘Click’, ‘Product page’]);’>Download Button</a>
</code>
The example above uses three parameters:
- Category: (Download Button)
- Action: (Click)
- Label: (Product Page)
These values are logged & visible via the Content > Events tab within the analytics dashboard:
Using different values for these parameters allows you to track different interactions across your site & see which areas perform better.
If I decided to add a new download link to the sidebar of my site for example I could use the following parameters:
- Category: (Download Button)
- Action: (Click)
- Label: (Sidebar)
The first two parameters stay the same as it’s still a download button, but now I can track the one in the sidebar separately as it has a different label.
And that’s pretty much it! It’s only a basic example of using events but it’s one I’ve found quite useful for giving me a rough idea of where people click & which areas are performing well.
If you’d like to know more, Google have setup quite a handy guide.
Filed under: