Follow

How do I add Google Analytics Event Tracking to a link?

Custom Google Analytics event tracking can be added to links, pages, and entire sites through the onclick attribute. What does that mean? It means you're adding tracking to an action taken by the user (or as we call it, an "event") and the event you're tracking is the "click".

How an "onclick" event is structured, and how you can create your own

Here's an example of the "tracker":

onclick="that=this;_gaq.push(['_trackEvent','EventCategory','EventAction',that.href]);"

Let's go through and explain the pieces you'll need to modify to make it work. 

EventCategory

This you can replace with your unique identifier of the webpage where the link appears that you're tracking. This will show up in the Google Analytics report, so make it unique and recognizable. You can't use spaces or special characters, so it might look something like this: e.g. WebComm-Training

EventAction

EventAction is the type of action the onclick event you are tracking performs. This is usually one of these three: Click, Toggle, or Download.

So, if we're building a tracker to monitor the amount of clicks our "View our Intro Training" link gets on our training page, it might look something like this:

onclick="that=this;_gaq.push(['_trackEvent','WebComm-Training','Click',that.href]);"

Now, let's show you where to put this on your link so it starts tracking. 

Placing the tracker you've built onto the link you want to track

  1. Login to your webpage, and begin editing the page you wish to add the tracker.
  2. Click the green button on the editable region you wish to edit (e.g. Main Content.)
  3. Highlight the link you wish to add the tracker.
  4. Click on the Advanced Tab.
  5. Paste your tracker into the onclick field.
  6. Click OK.
  7. Save and publish your page and you should now be tracking that link.

screen.png

Click on the link a few times to send tracking information through to your Google Analytics, however, the clicks may not show up right away. You may need to check back in a few days.

Was this article helpful? 0 out of 0 found this helpful

Have more questions? Submit a Support Ticket