Skip to content
Strategy

How to Set Up Google Analytics Event Tracking

If you want to track and record data that aren’t normally recorded in Google Analytics, you need to learn how to set up Google Analytics event tracking.

Tony Tran April 1, 2019
how to set up google analytics event tracking

So you’ve set up your website.

You’ve planned out your content calendar.

And you’ve even created a Google Analytics account to start tracking vital metrics for your business.

Awesome! But you’re probably asking yourself, “What now?”

After you’ve laid the foundation for your business’s website, it’s the perfect time to set up Google Analytics event tracking.

This allows you to track and record data that aren’t normally recorded in Google Analytics—giving you access to a wealth of data you wouldn’t be able to otherwise measure.

And there are two ways you can go about setting it up:

  1. Manually. This takes a little bit of extra coding know-how.
  2. Google Tag Manager (recommended). This requires little to no coding knowledge.

Let’s walk through both methods of setting up Google Analytics event tracking, and look at how exactly the tool works.

But first…

Bonus: Get a free social media analytics report template that shows you the most important metrics to track for each network.

What is Google Analytics event tracking used for?

To understand Google Analytics event tracking, you first have to understand what an “Event” is.

“Events are user interactions with content that can be tracked independently from a web page or a screen load,” according to Google. “Downloads, mobile ad clicks, gadgets, Flash elements, AJAX embedded elements, and video plays are all examples of actions you might want to track as Events.”

Elements can include things like buttons, videos, light boxes, images, and podcasts.

So Google Analytics event tracking is just the way GA measures and records a variety of different metrics related to visitor engagement with these elements.

For example, if you want to see how many people download a PDF you have on your website, you can set it up so that Google Analytics records that event every time it happens.

Some other things you can record using event tracking:

  • # of clicks on a button
  • # of clicks to outbound links
  • # of times users downloaded a file
  • # of times users shared a blog post
  • How much time users spend watching a video
  • How users moved their mouse on a page
  • Form field abandonment

When you couple it with your Google Analytics goals, event tracking can help prove the ROI of a marketing campaign.

Now that we know exactly what Google Analytics event tracking is used for, let’s take a look at how it tracks the events.

How does event tracking work?

Event tracking leverages a custom code snippet that you add to the elements that you want to track on your website. Whenever users interact with that element, the code tells Google Analytics to record the event.

And there are four different components that go into your event tracking code:

  • Category. The name that you give the elements you want to track (e.g. videos, buttons, PDFs).
  • Action. The type of interaction you want to record (e.g. downloads, video plays, button clicks).
  • Label (optional). Supplementary information about the event that you’re tracking (e.g. name of the video users play, title of the ebook users download).
  • Value (optional). A numerical value you can assign to a tracking element.

All of the above information is sent to your Google Analytics account via the event tracking code.

That means when it’s embedded onto a webpage, it’ll send information and metrics regarding the event you want to record back to your GA account in the form of an event report.

Now that you have a good idea about what event tracking is—and how it works—let’s jump into the two ways you can set it up.

How to set up event tracking manually

Between the two methods, this one is the trickiest—but by no means impossible.

You don’t need a masters degree in computer engineering to do some basic backend coding on your website. If you follow the steps below, you’ll be able to do that (mostly) pain-free.

Step 1: Link your site to Google Analytics

Set up Google Analytics if you haven’t already. If you need help with that, be sure to check out our article on how to set up Google Analytics.

Once you’ve done that, you’re going to have to find your Google Analytics tracking ID. This will be a snippet of code that links your GA account with your website.

You can find the tracking ID in the admin section of your account.

tracking ID Google Analytics
Source: Google

The tracking ID is a string of numbers that tells Google Analytics to send analytics data to you. It’s a number that looks like UA-000000-1. The first set of numbers (000000) is your personal account number and the second set (1) is the property number associated with your account.

This is unique to your website and your personal data—so don’t share the tracking ID with anyone publicly.

Once you have your tracking ID, you’ll now have to add the snippet after the <head> tag of each page on your website.

If you’re using WordPress, you can make this process even easier by installing and activating the Insert Headers and Footers plugin. This will allow you to add any script to the Header and Footer throughout your entire website.

Insert Headers and Footers plugin
Source: WPBeginner

Step 2: Add event tracking code to your website

Now it’s time to create and add event tracking codes.

The event tracking code is made up of the four elements we mentioned above (i.e. category, action, label, and value). Together, you use them to create a tracking code snippet that looks like this:

onclick=ga(‘send’, ‘event’, [eventCategory], [eventAction], [eventLabel], [eventValue]);”

Simply replace the category, action, label, and value placeholders with your own customized elements based on the events you want to track. Then place the entire code snippet after the href tag on your page that you want to track.

So in the end, it’ll look something like this:
<a href=”https://www.yourwebsitelink.net” onclick=”ga(‘send’, ‘event’, [eventCategory], [eventAction], [eventLabel], [eventValue]);”>LINK NAME</a>

Let’s run through an example:

Say your company wants to track the number of downloads you get on a lead magnet PDF. Your event tracking code might look like this:

<a href=”https://www.yourwebsitelink.net/pdf/lead_magnet.pdf” onclick=”ga(‘send’, ‘event’, [PDF], [Download], [Awesome Lead Magnet]);”>LEAD MAGNET DOWNLOAD PAGE</a>

Now every time someone downloads the PDF, it’ll be recorded and sent to your Google Analytics events reports page—which brings us to:

Step 3: Find your event report

Go to the main dashboard for your website’s Google Analytics. Click on “Events” under “Behavior” in the left hand sidebar.

Google Analytics menu

There you’ll find four event reports you can view:

  • Overview. This report gives you a broad high level look at the events on your website. You’ll be able to see the unique and total number of times users interacted with the elements you are tracking as well as the total value of those events.
  • Top events. This report shows you how popular certain events are, with the top event categories, actions, and labels shown.
  • Pages. This report gives you a breakdown of which pages have events in which you are tracking.
  • Events flow. This report gives you a visualization of your user’s experience. You’ll be able to see the “order in which users trigger the Events on your site.”

Check out the video below for more.

With these event reports, you’ll be able to prove the ROI of the elements you are tracking. You’ll also be able to determine what’s working, what’s not working, and what needs some fine tuning to give your users the best experience possible.

How to set up event tracking with Google Tag Manager

Now that you know how to manually set up Google Analytics event tracking, let’s take at a simpler method: Google Tag Manager (GTM).

GTM is a tag management system offered for free from Google.

The platform takes the data on your website and sends it to other platforms such as Facebook Analytics and Google Analytics with little to no backend coding on your part.

You’ll be able to update and add tags to your Google Analytics code without having to manually write code on the back end. This will save you a ton of time down the road.

For example, if you’re trying to track the number of downloads of a PDF. Using the above method, you would have to change all the download links everywhere on your website to do this.

However, if you have GTM, you’d be able to add a new tag to track the number of downloads.

Let’s jump in and see how exactly you can go about setting up GTM to make your event tracking easier and simpler.

Step 1: Set up Google Tag Manager

Create an account on the Google Tag Manager dashboard.

adding a new account in Google Tag Manager

Put in an account name reflective of your business. Then choose your country, choose whether or not you want to share data with Google, and click continue.

You’ll then be taken to this page:

Setup container in Google Tag Manager

This is where you will set up a container.

A container is a bucket that contains all of the “macros, rules, and tags” for your website.

Give your container a descriptive name and select the type of content it’ll be associated with (Web, iOS, Android, or AMP).

Then click create, review the Terms of Service, and agree to those terms. You’ll then be given the container’s installation code snippet.

Google Tag Manager snippet

This is the only piece of code you’ll be pasting into your website’s backend in order to manage your tags.

To do that, copy and paste the two snippets of code onto every page of your website. As the instructions say, you’ll need to the first one in the header and the second after the opening of the body.

As with Google Analytics, you can make this process even easier by installing and activating the Insert Headers and Footers plugin. This will allow you to add any script to the Header and Footer throughout your entire website.

Step 2: Turn on built-in variables

Now, you’ll need to make sure that GTM’s built-in variables are enabled in order to create your tags.

From your main GTM dashboard, click on “Variables” on the sidebar and then click on “Configure” on the next page.

defining variables of a container

From here, you’ll be able to choose all the variables you want to track. Make sure you have those variables marked with a check mark in the boxes.

choosing variables for container

Once you have all your variables chosen, you’ll be able to create a tag.

Step 3: Create a tag

Go to your Google Tag Manager dashboard and click on the “Add a new tag” button.

Adding a new tag

You will be taken to a page where you can create your new website tag.
On it, you’ll see that you can customize two areas of your tag:

  • Configuration. Where the data collected by the tag will go.
  • Triggering. What type of data you want to collect.

configuration button

Click on the “Tag Configuration button” to choose the type of tag you want to create.

You’ll want to choose the “Universal Analytics” option in order to create a tag for Google Analytics.

choose tag type

Once you click on that, you’ll be able to choose the type of data you want to track. Do that and then go to “Google Analytics Settings” and choose “New Variable…” from the dropdown menu.

Choosing "New Variable"

You’ll then be taken to a new window where you’ll be able to enter in your Google Analytics tracking ID. This will send your website’s data straight into Google Analytics where you’ll be able to see it later.

entering new Tracking ID

Once this is done, head to the “Triggering” section in order to select that data you want to send to Google Analytics.

As with the “Configuration,” click on the Triggering button in order to be sent to the “Choose a trigger” page. From here, click on “All pages” so it sends data from all your web pages.

choosing a trigger

When all is said and done, your new tag set up should look something like this:

Google Analytics tag

Now simply click on save and voila! You have a new Google Tag tracking and sending data to your Google Analytics page about your website!

What next?

Once you’ve set up your Google Analytics event tracking, congrats! You’re on your way to getting a fuller, more comprehensive picture of your website, business, and target audience.

You’ll be able to prove the ROI of a campaign, see what videos or links your users like to click on, and improve features on your website to better serve your audience.

Be sure to check out a few of our articles below that can help you get the most out of your Google Analytics and ROI experience:

It’s crucial that you know exactly what your data and metrics are when it comes to social media.

Drive more traffic to your website with the help of Hootsuite. From a single dashboard you can manage all your social media profiles and measure success. Try it for free.

Get Started

Become a better social marketer.

Get expert social media advice delivered straight to your inbox.

By Tony Tran

Tony is a freelance journalist and content marketing consultant. His work has been seen in Business Insider, Playboy, and Huff Post.

Related Articles

You’ve unlocked 60 days for $0
Hootsuite Offer