Introduction

Sometimes you want to track specific events that occur in your website and report over these metrics. Whether it be form signups, button clicks or page views, Google Analytics can do this for you.

With a little bit of coding you can easily leverage the reporting power of the Google Analytics dashboards and drill down into how your website visitors are behaving.

In this post, I’ll show you how to implement Event Tracking in your web site and view these in the Google Analytics admin console.  It assumes you have your analytics tracking code from the Analytics Admin dashboard embedded in your site.

Events

Straight from the Google developers site:

“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”

How to implement

The code is simple and can be implemented in one call in your ASP.NET web app.

GAEventSyntax

The following table summarises what each parameter means:

GATable

With the above in mind, you inject this call to relevant areas of your application that you want to report on.

For example, in my crime mapping prototype, I may want to track Events when a user has switched the heatmap on or off.  The following GA code would let me do this:

function toggleHeatmap() {
            ga('send', 'event', 'Button', 'click', 'heatmap');
            heatmap.setMap(heatmap.getMap() ? null : map);
        }

You can see that that I’ve added a hierarchy Button->-Click->Heatmap.

This makes it easier at the Google Analytics end to drill down into the Events. With this code in place we can move onto the reporting aspect.

Reporting

To me, Google Analytics is like a space shuttle control panel at times.  There are so many options and endless segments to pick from. To see our new Events being tracked in the GA admin console, you browse to the Behaviour menu and select Events.

GAMenu

Select Overview to show you the following screen which displays the new Events that we’re tracking from the button click.  This report doesn’t update in real time so you’ll need to give it a few moments to refresh with data.

GADashboard

Summary

That’s it’s for now.  In part 2 of this post, I’ll show you how you how to connect your Google Analytics reporting data to Microsoft Power BI.  This allows you to quickly create rich visual dashboards which contain all your analytics data.

JOIN MY EXCLUSIVE EMAIL LIST
Get the latest content and code from the blog posts!
I respect your privacy. No spam. Ever.