How does Google Analytics event tracking work?

A snippet of custom code is added to the link code on the items you want to track on your website and when the item is clicked, the element is tracked and displayed as an event in Google Analytics.

The event tracking code consists of four elements that you can define to describe a user’s interaction on your website:

  • Category (Required) is the name you give to a group of objects you want to track.
  • Action (Required) is the type of interaction, such as downloading a document.
  • Label (Optional) is useful for summarising what the event is about, such as clicks on navigation menu options.
  • Value (Optional) can be used if you’d like to assign a numeric value to your file download.

When the event fires on your site, the ‘Category’, ‘Action’, ‘Label’ and ‘Value’ attributes can be used to help you understand exactly what the user engaged with on your page. As mentioned above, it is important to give some thought to the naming conventions used for these attributes as these values are what will show within Google Analytics.

The event tracking code for an event tracked link in Universal Analytics looks like this:

onclick=”ga(‘send’, ‘event’, ‘Category’, ‘Action’, ‘Label’, ‘Value’);”

The code is placed after the href link text as illustrated in the example below

The category, action, label and value labels are replaced by the values that you decide to enter. An example of an event tracked link with entered values is further down the page.