Event Tracking. So Easy, Your Mom Could Do It.

Google Analytics Event TrackingOkay, don’t hate me just yet. It’s not that I think you can’t understand the other blog posts I have read about event tracking… But after spending hours and failing at multiple attempts when teaching myself how to set up Google Analytics event tracking, I realized that most of the guides out there are confusing and overwhelming. In fact, the best guide that I found using a Google Search had some incorrect code and some contradictory statements, which only made things more frustrating.

DISCLAIMER: This rambling is assuming you already have Google Analytics set up for your website. It is also intended for basic uses of event tracking for the everyday person. If you need additional help with the advanced stuff, send me an email and I can work with you directly.

The purpose of this Google Analytics event tracking “how to” is to simplify the process and make event tracking easy and painless for anyone. Yes, anyone… even if you think the word “code” has something to do with a super secret encryption message used in the movie National Treasurer (fun fact, a friend of mine from high school was an extra in that movie). Anyways, this guide will explain Google Analytics event tracking in good ole’ fashioned plain English.

The very basics, for the true beginners

(A.K.A. mom)

(If you are not a complete newb, you can skip to the next section)

For those of you who really are starting from square one here, let me lay out some simple explanations of event tracking and why you should be using it. Here are some frequently asked questions about event tracking that I have heard.

  • What is an event for a website?
    • An event is basically just a defined action that analytics can not track on its own, without event tracking in place.
  • What is event tracking?
    • Event tracking uses variables defined in your website code, which allows you to track how and where your website users are completing events.
  • Why is event tracking important for my online success?
    • Chances are, you are already spending a ton of time, money, or both on your website. Event tracking is the only way to identify which elements are helping you to reach your online goals. It is important that you (or your online partner like Ironistic) measure this data to determine where, and how, improvements can be made to increase your return on investment.
  • What types of events can I track with Google Analytics?
    • This could be a long list. I’ll cut to the chase and let you know how I personally use event tracking the most for our clients:
      • Email link clicks
      • Banner clicks
      • Ad clicks
      • Image clicks
      • External link clicks
      • Document downloads
      • Video plays
      • and the list goes on…
    • The cool thing is, you can track everything I mentioned above using pretty much the same method!

Okay, so let’s get to it.

I could write a few paragraphs explaining all the information in the Google Developer’s Guide, but this is event tracking made simple… so I will skip all the technical jargon. You can review Google’s guide here if you want to learn more.

Here is a quick reference guide for the elements of HTML code that we will be defining in the next step (bear with me, it’s actually not as bad as it seems).

This shows how the code is laid out depending on the version of analytics you use (don’t worry, I built a code generator for you, so you won’t have to memorize this!)

Classic Analytics (ga.js) – you may want to get with the times and upgrade to Universal Analytics

_trackEvent(category, action, opt_label, opt_value, opt_noninteraction)

Universal Analytics (analytics.js)

ga(‘send’, ‘event’, ‘category’, ‘action’, ‘label’, value);

Anatomy of event tracking defined

    • category (required)
      • “The name you supply for the group of objects you want to track.”
      • This is important because it determines how your data will be organized in Google Analytics. It can be anything you want really… let’s say you have 5 email links throughout your site you want to track. You could make the category for each one “Email Link.”
    • action (required)
      • “A string that is uniquely paired with each category, and commonly used to define the type of user interaction for the web object.”
      • Using the email link example above, the action here would simply be “click.” Some other situations may be appropriate for using “hover,” “download” “play,” etc.
    • label (optional)
      • “An optional string to provide additional dimensions to the event data.”
      • I typically make this the URL or Page Name. That way it is easy to identify where the event took place. Using our email example, if I label my email link in the footer, “footer,” I will be able to see in Google Analytics when someone “clicks”(action) on an “email link”(category) from the “footer”(label).
    • value (optional)
    • non-interaction (optional)
      • A boolean that when set to true, indicates that the event hit will not be used in bounce-rate calculation.
      • This can be useful if you are tracking an event that takes a user off of your website (which, honestly, if you are linking off your website you should always open in a new window!). This will exclude your click from being counted as a bounce.

Now for The Fun Part

Now that you understand the basics of what event tracking is and why you should be using it… here is where I want to make this easy for you. Fill out the form below and I will show you the exact snippet of code to place within the event you want to track. Be sure to check which Google Analytics code you are using because the event tracking will be different. Now you give it a try!

Hannah’s Ridiculously Easy to Use Event Tracking Code Generator

More Examples:

See the examples below for placement of your code (pasted code is in red):

Classic Analytics (ga.js)

<a href=”mailto:hwatkins@ironistic.com” onClick=”_gaq.push([‘_trackEvent’, ’email links’, ‘click’, ‘footer’,, ‘true’]);”>Email Me</a>
<a href=”/documents/registration-form.pdf” onClick=”_gaq.push([‘_trackEvent’, ‘downloads’, ‘download registration form’, ‘/documents/registration-form.pdf about us page right rail’, 3, ‘true’]);”>click here to download</a>

Universal Analytics (analytics.js)

<a href=”mailto:hwatkins@ironistic.com” onClick=”ga(‘send’, ‘event’, ’email links’, ‘click’, ’email link in footer’, 3,);”>Email Me</a>

<a href=”/documents/registration-form.pdf” onClick=”ga(‘send’, ‘event’, ‘downloads’, ‘download registration form’, ‘/documents/registration-form.pdf about us page right rail’, 3,);”>click here to download</a>

Tracking events for button clicks, image clicks, sidebar ad clicks, etc. is the same concept as above. Just add the snippet of code within the element that is being tracked. After you have added all of your event tracking code, you can view the data in Google Analytics by clicking on “Events,” under “Behavior.”

Well, there you have it! The simple guide: Google Analytics Event Tracking. So easy, your mom could do it. Hopefully you’ve learned something today that you can go to go forth, improve your website, and increase you goal conversions.

Related Posts


There are currenty 6 responses.

June 13, 2018

Hi! I have a very pesky site currently in SharePoint 2010.

I’d like to track user engagement with some of our downloadable forms, and the number of plays of our videos.
I’ve no idea where to start! We can’t use Google Tag Manager as it is incompatible with SharePoint 2010.

Any ideas?


    Hannah Taylor
    June 14, 2018

    Hi Sarah,

    You came to the right place! You can track form downloads and video playbacks using event tracking, as described in this post. You would not be required to have Google tag manager if you use the method above, you will just need to make sure you add the event tracking code in the proper place and based on which version of Google Analytics you are using. If you get stuck and need some additional assistance, feel free to reach out.

November 20, 2014

I have given an example of TestSafe website. Our website also has several pages like this with lot of pdfs and word documents (which can be downloaded), so it is not feasible to do the one shown in example for each and every URL in every page. So how to track word and pdf downloads for all the pages in one go? Is it possible to do this with one script in Master page of Sharepoint? Thanks

    Hannah Watkins
    November 24, 2014

    As far as I know, it needs to be done manually for each URL because the variables could be different for each. I am not a developer though, so there could be a way to write a script that will help with some of the heavy lifting.

November 19, 2014

How do you track several word documents and pdf downloads for Google analytics in a javascript code in a master page of Sharepoint site. The one that is mentioned is for one or two pdfs but our site has plenty of word documents and pdfs. So could you please send the code required to add in master page

    Hannah Watkins
    November 20, 2014

    Hi SP, can you send me a link of an example page containing the download links that you are trying to track? I would be happy to take a look and send you specific feedback. You can also feel free to email me at hwatkins@ironistic.com with more information if needed.

    The code for tracking a Word file download event would be the same as tracking a PDF file as in the examples above. You will need to identify the category, action, label, value (optional) and non-interaction as true or false. Then structure the event tracking code as required by your version of Analytics and insert the code into the the link or image element that will be clicked on to start the download of the document.

    I hope this helps!


Leave a Reply

Your email address will not be published. Required fields are marked *

Request A Quote
Let's take your business to the next level. Fill out the form below to get started!
  • This field is for validation purposes and should be left unchanged.