Skip to main content
King County logo

So, what exactly, is an "Event" in Google Analytics parlance? In the words of Google

Events are user interactions with content that can be tracked independently from a web page or a screen load. 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.

Focus on the word "interaction" for the key to understanding Events. Technically, an Event can track something as complex as users who visit a certain page, spend more than 30 seconds and scroll at least 3/4 down the page. If you really need something this complex, please email the WebTeam. For this tutorial, we'll focus on more realistic scenario, like your director/elected asks "Is anyone clicking the download button for my new report?"

The no-code option

One of the most popular uses for Event tracking in Google Analytics answers the question, "Did people download this document?"

Until recently, we hadn't enabled that feature globally, but we can now. If you want to know if someone downloaded your document, here's what you do:
  1. If you have an account, visit the "Behavior" left menu, "Events" and "Top Events"
  2. From there, select "Event Label"
  3. Use the search filter to find the URL of the document See a screenshot of this process.

I need something more specific

If you need to track a highly specific user interaction like "Did users click this button on my page?", you can add a small code snippet to track an Event in Google Analytics. 

In the CustomScriptBlock section of your page, add this jQuery snippet:


<script type="text/javascript">
$('#ID-GOES-HERE').on('click', function() {
  ga('send', 'event', 'CATEGORY', 'ACTION', 'LABEL');
});
</script>

In this code snippet, you'll be replacing the ALL CAPS sections. 

First, create an ID for the element you're targeting. It can be anything you like. Add that ID to the element in the HTML, and in the ID-GOES-HERE section of the jQuery code. Next we'll add CATEGORY, ACTION, LABEL. These are fields that feed into Google Analytics.

CATEGORY

A category is a name that you supply as a way to group objects that you want to track. We strongly suggest, to keep tracking easy and consistent, you use the same category every time, and name it for your department/division. EX: Assessor

ACTION

Typically, you will use the action parameter to name the type of event or interaction you want to track for a particular web object. For example, a document download would be "download" or a button click could be "click", etc.

LABEL

This is the field where you can describe exactly what the user is interacting with. For example, if it's an annual report, the label could be "Annual Report, 2015", or if it's a video about registering to vote, it could be "Voter registration video, 2015"

NOTE: Please add relevant dates to labels, or tracking a 2013 Annual Report and 2016 Annual Report could get mixed up. Additionally, if an event has an expiration date, add that to the label, too.