Google Analytics Event Tracking

Google Analytics Event Tracking

Have you ever noticed that the most successful e-commerce websites are also the most interactive? They have newsletters, on-page user reviews, product videos, user-generated photos and thriving communities of fans (just look at how Modcloth does it). In fact, the more successful an e-commerce website is, the more likely it is to have these features.

Save yourself from the missed steps and trial + errors and get our QUICK PRIMER for creating a tag for an event in Tag Manager document.

That’s no accident.

Interactivity improves sales.

But each interaction is a request for users to opt-in. And all of that opting-in means that conversion rate optimization is vitally important.

And in order to optimize to improve interactions, you’ll need to know how to track them – as “events.”

Enter Google Analytics Event Tracking

On its default setting, Google Analytics tracks a lot – but it doesn’t track events (events = interactions). Right out of the box, GA is setup to track individual sessions and pages, bounce rate, time spent on page, average session durations, and other metrics tied to the page. It can also recognize individual users, if they use the same device and browser.

But this sort of tracking doesn’t tell you what visitors did on the page. Just that they were there.

If you go to your Google Analytics account right now and look at the left-hand pane, you’ll find the Event subsection. Click on it, and you won’t find much – it will remain empty until you enable event tracking to populate the report.

Google Analytics is ‘aware’ that events exist on the page, but without event tracking, the report does not contain the instances of events that took place on individual pages.

To get that intel, you’ll have to customize Google Analytics.

Don’t worry – even for relative beginners, it’s not that hard. We’ll walk you through it.

What is event tracking and how can I enable it in Google Analytics?

Google Analytics event tracking is a piece of JavaScript that is inserted in interactive content on website pages. JavaScript is a programming language used mostly to create dynamic content on websites – content that moves, reacts, changes and does things. In this case, we’re using the JavaScript code to initiate the report from the web page to Google Analytics when an event has taken place on the website page.

Once the JavaScript code is applied to a link or button, it reports to Google Analytics every time a visitor interacts with the content.

This piece of code is called a tag.

Tags can be triggered by actions you predefine and they tell Google Analytics what values to report in the Event part of the Behavior section.

For example, one interaction might be clicking on the ‘Add to cart’ button. If we add a JavaScript tag to the button, we can ‘tell’ Google Analytics that a visitor has clicked the button.

Any interaction is an event, from clicking a link to viewing a video, or filling out a form.

Google Analytics defines an event is by four attributes:

  • Category – the broad group the event belongs to, like “T-shirts.” An example would be how Amazon sorts the products on their site – books, clothes, home goods, etc.
  • Action – what action will be reported to Google Analytics (download, viewed video, filled form). You can enter your own values or use pre-listed options.
  • Label – this tells Google Analytics the precise resource, document or individual item that generated the event. For example, if the category is “T-shirts,” the label may be “Women’s Short Sleeved Shirt.” Labels can be used to track the popularity of individual items in the product catalog, or posts, if the site we analyze is a blog. They’re optional.
  • Value – you can assign each event a “value” (it’s like a goal). If the event is given value, it will be recorded by Google Analytics. The values are then reported in total, per event or average. This can be used to give non-revenue creating events to judge their relative significance or to measure the value of real transactions.

If the “event” leads users off the page, we can set it as a non-interaction so it doesn’t get recorded as a “bounce.” To do this, set it to “true.” Doing this helps us more accurately record the page and/or CTA button’s success.

For e-commerce web sites, event tracking primarily means tracking macro conversion events (completed sales, or submitted forms). The second priority is tracking events like visitors clicking links to go off site. And finally, tracking micro conversions, like watching videos, newsletter signups and downloads.

When we want to start implementing event tracking, the first thing to do is to make a list of events that need to be tracked. Next, we need to sort them into categories and finally define the triggers.

How to implement event tracking

To track events in Google Analytics, the website must send the relevant data to Google Analytics to create the necessary reports (hits) and populate the Google Analytics Behavior section and the Events subsection with the data. The website does this with a piece of script that looks like this:

_trackEvent(‘category’, ‘action’, ‘label’, value)

This script should be inserted in the line with the event we want to track.

Of course, if you were to do this by hand with every single interaction on every page of your website, it would take you a very long time. And, if you forgot one, you’d lose a lot of data, and really gunk up the reliability of your Google Analytics reports.

To avert disaster, we should use Google Tag Manager.

Simplify your life (and code) with Google Tag Manager

Setting up event tracking in Google Tag Manager is very simple.

In the Tag tab select ‘New’ and a dialog box will open:

Setting up event tracking in Google Tag Manager
Setting up event tracking in Google Tag Manager

Here, click inside the Tag Configuration box and a following dialog will open:

Tag configuration box
Tag configuration box

In this dialog box, select Universal Analytics, and arrive at the next screen:

Google Analytics event tracking Universal Analytics define
Google Analytics event tracking Universal Analytics define

Here, insert the Tracking ID code of the web site and select “Event” as the track type in the bottom drop down menu. Once you select Event, from the drop down menu you will get the following fields:

Google Analytics - Define event
Google Analytics – Define event

Here are the attributes of the events. Once you fill those with values, all that is left is to assign a trigger, save the tag and publish it.

If properly configured, Google Tag Manager will automatically insert the script to every line containing the event needed to track.

Assigning a trigger is also made easy by the Tag Manager. For more information on how to configure the Google Tag Manager and create tags, consult our Google Tag Manager article.

Note: You might be able to use a plug-in!

Google Analytics has the additional ability to track e-commerce events through the Enhanced e-commerce plug-in which is available for several e-commerce website providers.

Here is a short checklist on how to use event tracking:

  1. First off, you need to define the event you want to track. Once you do that, you will be able to structure the event tracking code and implement it through the tag manager
  2. To establish proper tracking, you need to give the events Category, Action, Label and Value. These will tell Google Analytics how to report the events once they happen. For example, if you track outbound links clicks, you will use the Category ‘Links’, Action ‘Click’ and Label ‘Outbound’. Label and Value are optional fields. Use Value if you want to compare the relative significance of events.
  3. You also must define what triggers the event on the page. Triggers are defined through Tag Manager and they determine when the certain event will fire. This condition can be anything, from a simple page view to more complicated structures of multiple conditions.
  4. Variables are an important part of event structure and they are used to set custom values or to trigger the events once certain threshold has been reached (timers or total values of something and so on).
  5. You may need to write some custom code to enable Tag Manager to properly track the event triggers and variables. If that is the case, this code will be JavaScript and it can be implemented directly through Tag Manager in the form of Custom HTML. Just paste your code in the field and Google Tag Manager will automatically place on the website, without the need of any outside intervention.
  6. Once you publish the tag, make sure it functions properly using the Tag Manager preview mode. If it works correctly and Google Analytics real time mode tracks the events, you have succeeded. If not, go back to the drawing board. Google Tag Manager preview mode works as a debugger and will help you to find the error and correct it.
Save yourself from the missed steps and trial + errors and get our QUICK PRIMER for creating a tag for an event in Tag Manager document.
Series Navigation<< Google Tag Manager for e-Commerce StoresGoogle Analytics Multi-Channel Funnel >>

Published by

Edin is a Senior CRO Consultant. Edin is into Google Analytics and testing (any A/B testing tool really) and likes to write about it. You can follow Edin on Twitter.