Google Analytics is one of the best data-driven marketing tools available today. Managed by the world’s largest search engine, it provides you with detailed, day-by-day analysis of how users are interacting with your website. Tools like Google Analytics are incredibly powerful when it comes to measuring the engagement and effectiveness of your site and they can answer many questions when it comes to learning about your visitors.

But what if you wanted to dig deeper into your data and see exactly how users are interacting with your content? By default, Google Analytics only tracks information relating to page-views and visitors which gives you metrics like sessions, page-views and bounce rate. If you want to track things like clicks on links, PDF downloads, button clicks, form submissions, or even Mailto and Tel links, you have to set up event tracking.

What Is Event Tracking?

Event tracking in Google Analytics gives you the ability to measure how users interact with your website. This is done by adding an event tracking code to the elements on your site that you want to track. When a user comes to your site and clicks on the element, it will automatically tell Google Analytics to record the interaction.

There are four variables to consider when creating an event; Category, Action, Label and Value.

Category (required) – This variable specifies the type of object that was interacted with.
Action (required) – The specific action a user took to trigger an event.
Label (optional) – Allows you to provide more context about the interaction.
Value (optional) – The numerical-value of the event.
NonInteraction (optional) – A boolean that when set to ‘true’ (or “1” for Universal Analytics) excludes the event from affecting metrics like Bounce Rate.*

*By default, Google Analytics considers events as an “interaction”, which in turn affects your bounce rate.

Classic Analytics vs Universal Analytics

In recent years, Google has unveiled their Universal Analytics platform which provides extra features and compatibility not found in previous versions of Google Analytics. It’s important to know which configuration you have because the tracking code is not the same for both setups. Classic Analytics is based on the ga.js Javascript library whereas Universal Analytics is based on analytics.js.

Here is an example of the tracking code for Classic Analytics using ga.js:

onClick=”_gaq.push([‘_trackEvent’, ‘category’, ‘action’, ‘opt_label’, opt_value, ‘opt_nonInteraction’]);”

Here is an example of the tracking code for Universal Analytics using analytics.js:

onClick=”ga(‘send’, ‘event’, ‘category’, ‘action’, ‘label’, value, {‘NonInteraction’: 1});”

If you are not sure which version of Google Analytics you are using, there are a couple of ways to find out.

In Your Google Analytics Account

Go to your Google Analytics account and click on the “Admin” tab and look under the “Property” column. Classic Analytics accounts have an option called “Tracking Code” whereas Universal Analytics accounts have an option called “Tracking Info” that has additional options below it.

Another way to find out which version you are using is to look at the tracking code snippet under “Tracking Info/ Tracking Code” and look for which JavaScript library it is using.

On Your Website

You can also find out which version you are using by looking at the code on your website. To do this, open up the “Page Source” for your site. Using CTRL+F, search for either “analytics.js” or “ga.js” and whichever one appears on your site can be correlated to the version of analytics installed on your site.

How To Set Up Event Tracking

Step 1: Decide What You Want To Track

Before you go crazy and start adding tracking to your site, you want to take some time to prioritize which actions on your site that are most important to converting visitors. It should go without saying that your site has a specific purpose and that a user is visiting your site for that purpose. There are a number of different things that you can add tracking to:

  • Calls-to-Action (CTA’s)
  • Downloads
  • Sign-ups
  • Form submissions
  • Email addresses
  • Phone calls
  • Outbound links

Step 2: Add Tracking Code To Your Website

Now that you’ve figured out what items you want to track, it’s time to add the code to your website!

To add the code, you will need to insert your snippet into a link so that when someone clicks on it, Google Analytics will know that an event has been triggered and record it. You do this by passing the “onClick” JavaScript function.

For example, below is the code for a PDF Download link:

<a href=”http://mywebsite.com/ebook.pdf“> Free “SEO For Beginners” eBook </a>

Now, here is the same code with Classic Analytics Tracking (ga.js):

<a href=”http://mywebsite.com/ebook.pdf” onClick=”_gaq.push([‘_trackEvent’, ‘ PDF Downloads’, ‘Click’, ‘SEO For Beginners’);”> Free SEO For Beginners eBook </a>

Here is the same code for Universal Analytics Tracking (analytics.js):

<a href=”http://mywebsite.com/ebook.pdf” onClick=”ga(‘send’, ‘event’, ‘ PDF Downloads’, ‘Click’, ‘SEO For Beginners’);”> Free “SEO For Beginners” eBook </a>

For this event, the variables have been defined as so:

Category = PDF Downloads
Action = Click
Label = SEO For Beginners
Value = (none)
NonInteraction = false

Breaking it down, the category is called “PDF Downloads” because I want to track PDF downloads across the entire site. The action is called “Click” because a user needs to click on the link in order to view the PDF. The label has been set to “SEO For Beginners” because that is the name of our fictional PDF. We haven’t assigned this event a value so it doesn’t need to appear in the code. NonInteraction is set to false by default (meaning that this event DOES count as an interaction) so there is no need to include it in the code.

Step 3: Set Up A Goal In Google Analytics

Now that we’ve added to the code to our website, it’s time to set up a goal for our event in Google Analytics. To do this, log in to your Google Analytics account.

Go To “Admin”

 

Under the “View” column, click on “Goals”.

 

Click on “New Goal”.

 

Under “Template”, click on “Custom”.

 

Choose a name for your goal and then under “Type”, select “Event”.

 

Enter your category and action.  Verify your goal and then click “Create Goal”

.

How To Test Your Events

Before you call it a day, you need to test your event to make sure that it has been implemented properly. To do this, you need to go to the “Reporting” tab and click on “Real-Time” and then “Events”.

Go to your website and click on your event and when you switch over to Google Analytics, you should see the event pop-up. Confirm that it has the correct Category, Action and Label.

Event Tracking and Bounce Rates

As mentioned previously, events in Google Analytics are considered “Interactions” which is part of the formula used to calculate Bounce Rate. With more interactions per page, your bounce rate is likely to be impacted by these additional interactions.

To stop Google Analytics from using the event in Bounce Rate calculations, you need to set the NonInteraction variable in your tracking code to ‘true’. The process for this is again different between the two versions of Google Analytics. Using the same example from above, here are the tracking codes with NonInteraction set to ‘true’.

Classic Analytics (ga.js):

<a href=”http://mywebsite.com/ebook.pdf” onClick=”_gaq.push([‘_trackEvent’, ‘ PDF Downloads’, ‘Click’, ‘SEO For Beginners’, , true);”> Free SEO For Beginners eBook </a>

Universal Analytics (analytics.js):

<a href=”http://mywebsite.com/ebook.pdf” onClick=”ga(‘send’, ‘event’, ‘ PDF Downloads’, ‘Click’, ‘SEO For Beginners’, ,{‘NonInteraction’: 1});”> Free “SEO For Beginners” eBook </a>

The first thing that is important to note is the null/space used to represent our non-existent value variable. Whenever we do not use one of the optional variables, we need to include a null/space as a placeholder so that Google Analytics doesn’t get confused when your tag is fired.

By default, NonInteraction is set to ‘false’ so for Classic Analytics, you simply need to set it to ‘true’. Universal Analytics, however, is different in that you need to define the variable within two curly brackets and set it to ‘1’ ie {‘NonInteraction’: 1}

Examples of Event Tracking

Email Address Tracking:

<a href=”mailto:[email protected]”> [email protected] </a>

Classic Analytics (ga.js)

<a href=”mailto:[email protected]” onClick=”_gaq.push([‘_trackEvent’, ‘ Mailto’, ‘Click to Email’, ‘[email protected]’);”> [email protected] </a>

Universal Analytics (analytics.js)

<a href=”mailto:[email protected]” onClick=”ga(‘send’, ‘event’, ‘ Mailto’, ‘Click to Email’, ‘[email protected]’);”> [email protected] </a>

Category = Mailto
Action = Click to Email
Label = [email protected]

Telephone Link Tracking:

<a href=”tel:15558551234″> 1 (555) 855 1234 </a>

Classic Analytics (ga.js)

<a href=”tel:15558551234″ onClick=”_gaq.push([‘_trackEvent’, ‘ Phone Call’, ‘Click to Call’, ‘15558551234’);”> 1 (555) 855 1234 </a>

Universal Analytics (analytics.js)

<a href=”tel:15558551234″ onClick=”ga(‘send’, ‘event’, ‘ Phone Call’, ‘Click to Call’, ‘15558551234’);”> 1 (555) 855 1234 </a>

Category = Phone Call
Action = Click to Call
Label = 15558551234