How To Set Up Event Tracking in Google Analytics (via Google Tag Manager)

How To Set Up Event Tracking in Google Analytics (via Google Tag Manager)

Why Do You Need Event Tracking in Google Analytics?

By default, the standard Google Analytics Pageview tag (that is the code you implement on your website to set up the standard implementation of Google Analytics), as you might expect from it’s name, tracks only page-view related metrics. I’ve written a separate blog post which gives a detailed overview of what’s tracked by this standard implementation and what’s not. Some examples, though, are:

  • Downloads
  • Video Plays
  • Scroll Depth
  • Button Clicks
  • Outbound Link Clicks
  • Form Submissions
  • Widget Interactions

For those items / actions you cannot track automatically, you’ll need to add event tracking tags, which send the data to your Google Analytics reports only when visitor completes a particular action on your website (e.g. any of the above listed actions).

How To Set Up Event Tracking in Google Analytics?

There are two ways you can set up event tracking in Google Analytics. One way is to add each piece of event tracking code manually. The other is to set up tracking through Google Tag Manager. The Google Tag Manager method is by far the more straightforward, efficient and flexible, particularly if you have no coding experience.

Google Analytics: Universal Analytics Tags in Google Tag Manager

There are a number of Google Analytics: Universal Analytics tag templates available to you in Google Tag Manager which allow you to send data from your site to your Google Analytics property. The most common is the Pageview type which is used to send standard page-view data to your property. However, you can also choose from the following types to send different types of data to your Google Analytics property (with a little bit of custom configuration):

  • Event
  • Transaction
  • Social
  • Timing
  • Decorate Link
  • Decorate Form
Google-Analytics-Universal-Analytics-Tags-in-Google-Tag-Manager
Google Analytics Universal Analytics Tag Types

Today, we’ll be focusing on the Event type tag.

Event Type Tags

Event type tags allow you to send event tracking ‘parameters‘ to your Google Analytics reports. How you configure these ‘parameters’ defines what information is sent to your Google Analytics property.

Event Tracking Paramters
Google Analytics Event Type Tag: Tracking Parameters

The values that you set for these parameters defines what data will be sent to Google Analytics and what property it will appear in. When these parameters have been configured and a trigger has been connected to your tag, data will be collected and available to you in a number of reports in your Google Analytics property – the most straightforward way to view topline “event” data is to go to the Behavior > Events > Top Events report.

Google Analytics Top Events Report
Behavior > Events > Top Events report

As you’ll see, we can view events by each of the parameters that are configurable in Google Tag Manager – in this report these parameters are tracked as Dimensions – Event Category, Event Action and Event Label. We’ll come back to this report later – for now, back to Google tag Manager.

Setting Event Tracking Parameters

There are no official guidelines or best practices for configuring the Category, Action, Label and Value parameters for your Event tracking tags – you are free to follow whatever approach you like – the key advice I would give you in terms of naming conventions for these parameters is to be consistent! A simple approach to follow as a beginner is:

  • Category: This is the general category of the event e.g. “Form”, “Button”, “Video”, “Outbound Link”
  • Action: This is the action that occurred during this event e.g. “Submitted”, “Clicked”, “Played”, “Paused”.
  • Label: Additional information about the about the event like what form is being filled, what button is being clicked, what video is being played, what link is being clicked, etc.
  • Value: If you’re going to use the event as a Goal which has a specific monetary value to your business, you can assign a value to the event. Otherwise, I’d suggest leaving this blank for now.

The Non-Interaction Hit parameter can be left as False in most cases – read more about non-interaction hits here.

As for the Google Analytics Settings parameter, here you will select your Google Analytics Settings variable which you should have set up when implementing your standard Google Analytics Pageview Tracking tag.

Here’s an example of a fairly simple tag configuration to track all outbound links from my website:

Example Tag Configuration: All Outbound Links

The Category parameter has been set to “Outbound Link” which is self explanatory, as is the Action parameter which has been set to “Click”.

I have set the Label parameter as “{{Click URL}}” which is one of a range of built-in variables available to you in Google Tag Manager. This variable grabs the URL of whatever element is clicked (if it has one).

I have left the Non-Interaction Hit parameter as “False” and I have set the Google Analytics Settings parameter to the Google Analytics settings variable that I had set up previously, so that the data is sent to my Google Analytics property.

Google Analytics Settings Variable in Google Tag Manger
Google Analytics Settings Variable in Google Tag Manger

So now that we’ve set up our tag to send data to our Google Analytics property, we now need to tell the tag when to send that data… for that, we need a Trigger.

Creating A Trigger For Our Google Analytics Event Tag

In Google Tag Manager, a trigger listens to your website for certain actions like form submissions, button clicks, or page views. Triggers are evaluated when code on the page or app is executed, and associated tags are fired or blocked when the trigger conditions are met.

Trigger Types in Google Tag Manager
Trigger Types in Google Tag Manager

There are a number of different types of Trigger to choose from by default in Google Tag Manager. In the specific case of our Outbound Link tracking tag, we will be focusing on a Click type trigger, specifically the Just Links trigger. Logically, this makes sense given that the purpose of our tag in this example is to track all outbound link clicks from our website.

Without editing this trigger, it will fire the tag on all link clicks on the website. The problem with this is that it would include internal link clicks as well as outbound link clicks, e.g. menu item clicks or clicks from one page to another related page on your site via a hyperlink. So we need to configure the trigger to be a little bit more specific. We do this by selecting Some Link Clicks which allows us to restrict the trigger to fire only when specific conditions in relation to the link clicked are true.

We can choose from a number of combinations of variables, conditions and values to restrict the trigger. In this case, I will select the variable Click URL, the condition does no contain and I will manually enter the value “google-analytics.ie” which will ensure that the trigger will only fire when a user clicks on a link that points to a URL that is not on my website.

Outbound Link Click Trigger Google Tag Manager
Outbound Link Click Trigger Google Tag Manager

Once we save this trigger and associate it with our Tag, our job is done…almost…

Debugging with Preview Feature of Google Tag Manager

Google Tag Manager’s Preview Mode allows you to view the site on which your container code is implemented as if the current container draft was deployed, so that you can test a container configuration (i.e. new tags, triggers and variables) before it is published. 

Once you’ve finished setting up your event tag(s) as per the steps above, click on the “Preview” button on the top right corner to enter the preview mode.

Preview Mode in Google Tag Manager
Turning on Preview Mode in Google Tag Manager

Now with the Google Tag Manager tab still open, open your website in a new tab (on the same browser). You will now see a debugger section at the bottom part of your screen that looks like the screen below.

Google Tag Manager Preview and Debug Mode
Google Tag Manager Preview and Debug Mode

The panel on the left hand side shows all actions you have taken on your website, whilst the main section on the right hand side shows which tag fired (or did not fire) on each of the actions.

When you click on an outbound link, you should see that our tag in the main section on the right hand side. If not, go back and double check all the steps to make sure everything is correctly configured, and try again until it works.

Once you’re happy that the tag is firing correctly, go back to Google Tag Manager and Submit and Publish all the changes you have made for event tracking. Now… you’re actually done.

If you are having any difficulty with any of the steps outlined, feel free to get in touch via the form below.

Get in Touch: