How to add event tracking in Google Analytics

What is an Event?

In Google Analytics, an event is the notification that a user has done a pre-defined action. Events are a range of actions that take place on your website. They are not tracked by default, but it is possible to set up tracking for actions such as :


Downloading AdWords Editor

Downloading Software

Playing a Video

Or filling out a contact form, or doing almost anything on a page. If the user has done something to a part of the page, it can be tracked as an event in Google Analytics.

How do you see Events in Google Analytics?

Navigate to the Reporting view. Then, on the left scroll bar, scroll down to Behaviour -> Events -> Overview.

Adding Event Tracking Functionality

function trackEvent(Category, Action, Label, Value){

ga(‘send’, Category, Action, Label, Value);


This is the most basic model. There’s no guarantee this is the best method for tracking all types of events, but it’s a simple and easy enough method for most cases.

We use Universal Analytics – if you don’t know what this is, but you made an analytics account in the last year, you probably use it!

For us, on our People Page we want to know if users are clicking on the social profiles of our members. It’s a useful way of seeing if people are starting to engage and what type of people are likely to engage.

When a button is clicked, we call our version of trackEvent with the parameters social and person – which we use for our Category and Label. So you can imagine your event having trackevent(Category, Label) instead of (social, person) if that makes it easier!

So ours looks like this

What’s involved in an Event?

There are four elements of sending an event – Category, Action, Label, Value. 

ga(‘send’, {
hitType: ‘event’,
eventCategory: ‘CategoryName’,
eventAction: ‘ActionName’,
eventLabel: ‘LabelName’,
eventValue: ‘1’

Describes the Object involved in the Event

Describes the action that led to an event – ‘click’, ‘play’, send’, etc.

Optional – The category the event falls into

Optional – any number associated with the event

Category, Action, and Label are all text variables. You can send anything  you want as the names and it’ll show up in Google Analytics that way. Only Category and Action are essential, Label and Value are optional.

Then on each object you want to track, you ensure that it calls the function TrackEvent with the variables you want to track. So, in our case we’re tracking social buttons.

Implementing Event Tracking

WordPress Users can use the WP Google Analytics Event Plugin, which has been fairly well received.

Other users will have to call the Javascript we described earlier. The easiest method of calling this function is with the onclick attribute for buttons in HTML:

<button onclick=“TrackEvent(Action, Category, Label, Value)”>ButtonText</button>

Where all users have to do is add in the “onclick = “TrackEvent()” part to all relevant buttons, ensuring that the relevant Actions, Categories, Labels etc are captured by the website.

or using a jquery .click method:

$( “element”).click(function() {
var Category = “Category”;

Which can change the appropriate variables before the event data is sent to Google Analytics, using the TrackEvent function discussed earlier.


Then log back into Google Analytics and check to see if the events are coming through, you’re sorted!

If you need any help with any of the above, feel free to message me at @analyticalissa or through our Contact Form.


Chris Adams