There are a lot of visitors coming on your website. They are performing myriad of actions on different pages of your website. There’s a contact form, an affiliate link, a blog comment, and a blog rating. Visitors are using chat, downloading eBooks and whitepapers and subscribing to newsletters. To make intelligent decisions about your website and to know if things are working, you need to track all these events. Google Analytics offer a feature, Event Tracking, to help you do that. In this blog post, I will tell you how to set up event tracking google analytics using an example.
What is Event Tracking?
Event tracking is a Google Analytics feature which allows you to track the actions users take on your website . User actions takes a variety of forms on a website. It may be a contact form submission, whitepaper download, blog comment, link click, video view, etc.
The Basics of Event Tracking
To set up an event tracking, Google Analytics ask you to pass four following information fields about an event:
- Category: grouping events into desired tracking groups
- Action: the action the user takes
- Label: to differentiate this event among others (optional but recommended)
- Value: perceived value of an event (optional)
There is a fifth one as well, non-interaction, which we will discuss a little later because it doesn’t add any substantial data. These four parameters are passed in a form of code.
ga(category, action, opt_label, opt_value, opt_noninteraction)
You need to add information for the action you want to be reported in this format. Category and action fields are mandatory while label, value, and non-interaction fields are optional.
The code is added to the website which looks like following in its final form:
onClick=”ga(‘Category’, ‘Action’, ‘opt_label’, ‘opt_value’);”
How it works? An example
Let’s start with the most basic of the actions: an eBook download. Suppose you have just put a free eBook for download on your website and you want to track its downloads.
Now, let’s define the parameters for this event.
- Category: ebook (This represents all eBook activity across the website)
- Action: download (All download actions across the website)
- Label: Reading is Fun (This is to distinguish it with other ebook resources, if you have any)
- Value: 10 (This value can be anything based on your business requirements. People often use it to measure dollars they earn with each action. The idea is to quantize the value of each click.)
- Non-interaction: true (‘true’ means this event has nothing to do with bounce rate)
Now, map these values on the framework we mentioned earlier:
ga(‘ebook’, ‘download’, ‘Reading is Fun’, 10, true)
Now, since we want to track the click on each download button, this form will translate to:
onClick=”ga(‘ebook’, ‘download’, ‘Reading is Fun’, 10, true);”
Then, we will add the code in the link as:
<a href=”/downloads/ebook/reading-is-fun.pdf” onClick=”ga(‘_trackEvent’, ‘ebook’, ‘download’, ‘Reading is Fun’, 5, true);” target=’_blank”>Reading is Fun eBook</a>
Simply speaking, the extra line of code simply sits in the link to make the tracking happen. You can use this same strategy for all kinds of event including signs ups, logins, form submissions, video views, social sharing button interactions, and everything else that happens on your website.
Please feel free to ask your queries or give suggestions in the comment section. Want to learn more on Google Analytics? Subscribe below.