Event Tracking in Google Analytics
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:- If you have an account, visit the "Behavior" left menu, "Events" and "Top Events"
- From there, select "Event Label"
- 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
ACTION
LABEL
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.