Google Analytics Tutorial: Events Tracking

Events Tracking

Lots of things can happen in a website today. You can play a video, subscribe to a newsletter, even play flash games! Would you be able to track if your users are engaging in these activities in your website with Google Analytics? With the usual tracking code, you can’t. So let’s make some tweaks and make sure you’re tracking these valuable interactions shall we?

Pinpointing each Activity

People go in your website to do a certain activity. Either it’s to read the information in your page, watch a video, play a game, or simply send you an email using your contact form. Whatever it is, you can track it and collect the data as a Goal (See our Google Analytics Goal Tracking Tutorial here) or as an event or even both. This data can be used to further improve your website – such as whether to put the email subscription form in the sidebar or as a pop-up or which of your advertisements are getting the most attention / clicks.

Hands in the Mud

So let’s get our hands dirty. Before we start, make sure you have your Google Analytics Tracking code installed in your website.

The code is something as simple as:

onClick=”_gaq.push(['_trackEvent', 'Event Category', 'Event Action', 'Event Label']);”

Attach this code to a link or a button in your website. Here’s an example:

<a href=”” onClick=”_gaq.push(['_trackEvent', 'Event Category', 'Event Action', 'Event Label']);”>Your Anchor Text</a>

What this code does is it tells your Google Analytics Tracking code to track an event happening in your website. And whenever someone clicks this link where the code is attached to, it will record the event.

Let’s take a real example that I use here in the SEO Hacker website. See this sidebar?

SEO Hacker Sidebar

If you check out the code behind this sidebar, I applied the onClick Events Tracking Code to all of ‘em. The code looks like this:

<a onclick=”_gaq.push(['_trackEvent', 'Google Plus SH Page Sidebar', 'SEO Hacker G Page', 'Visited our Google Plus Page']);” rel=”publisher” target=”_blank” href=””>Follow us on Google+</a>

It means that when someone clicks on one of these links, it will automatically tell Google Analytics that someone clicked it. It will specify which of the links the user clicked and where the user went. The sample code tells me that the user went to my Google Plus page through this sidebar link.

Inserting the code is a piece of cake – unless you have a TON of things you want to track in your website. So don’t track each and everything a user does – only that which is important. Besides, you wouldn’t want to dilute the important events in your website with the unimportant and ‘common’ ones.

Tracking Events through Forms

Usually a form has some sort of button such as my Email Subscription form on the right sidebar:

SEO Hacker Email Form

You can put the onClick code in the ‘input’ part of the code like this:

<input onClick=”_gaq.push(['_trackEvent', 'Sidebar Email Form', 'Email Subscribed', 'SEO Hacker RSS Subscribed']); name=”submit” id=”af-submit-image-1013632171” type=”image” class=”image” style=”background: none;” alt=”Submit Form” src=”” tabindex=”502“/>

It’s fairly simple – now Google Analytics gets to track each time someone subscribes to our Email RSS feed using this form. Right now I have no other email forms in my website but if I do, I can put another events tracking code in it so it would track which is the better, more effective form in gathering leads.

How it Looks Like

On your Google Analytics Sidebar, go to Content -> Events -> Top Events.

Google Analytics Events Section

This is how your events would look like in the Top Events section in your Google Analytics. As you can see, most of my events come from outbound links. Tracking outbound links comes with a different code which we will tackle in our Google Analytics Tutorial series.

Google Analytics Top Events

You can also check out on which pages most of your events happened. Of course, you could always combine the data using Segments if you want to see exactly which Event happened on which Page.

Analytics Events Pages

Events tracking is simple and easy. Events Tracking is also highly overlooked. Don’t waste any time. The earlier you apply this in your website, the more valuable data you can look back to. That data can be your basis for A/B testing of forms, buttons, links, videos, etc.

Learn from your user activity, apply that data to your website, test. That’s what Google Analytics is about.

From Zero to a Thriving SEO CompanyWe're sharing everything on our Journey to $50K in monthly revenue.

You'll want to get in. Promise.

We guarantee 100% privacy. Your information will not be shared.

Monthly Revenue
  • Abhishek Jacob

    Thanks for sharing! helpful.

  • http:/ jose

    hello sean im a beggining to learn seo and i got to say by far your website has a lot of useful knowledge. keep up the great work

    • Sean

      Thanks Jose. Tell me how this tutorial has helped your business out. Hope to see more of you in the site!

  • Santosh Mane

    Hi Sean
    Google Analytics Tutorial help me to check my website report and other seo strategy like keyword, monthly click etc.

  • SEO Solvers

    Great post. Thanks for the insight. A lot of sites I build use Contact Form 7 and setting up event tracking allows us to track form fill outs.

    • h3sean

      It’s really useful if you make set your events up to be a goal. That way you know exactly how many people have hit the ‘send’ button over a span of time especially if you’re not on the receiving end of that contact form.

  • PPC Blast

    Great post Sean. With Analytics upgrading to Universal _gaq.push doesn’t work anymore and takes jQuery to implement event tracking. I wrote an article a couple of days ago detailing it for all that are interested.

    Thanks for the post!

    • h3sean

      Thanks for the heads-up about this. I’ll look into it and perhaps create my own as I test your tutorial out.

      • PPC Blast

        No problem. Thanks for giving it a read. I hope it does help. If there is anything you think I should add feel free to let me know.

        • h3sean

          I reviewed my events tracking code. It still works and tracks the events I set it for though. I guess the oldschool way still works.

          • PPC Blast

            Great deal. I first noticed it when I tried to use the old way on a website using Universal and nothing, then while doing research found the jQuery method and it worked. I am glad to hear that the oldschool method still works. Thanks for the update on that :)

          • PPC Blast

            I found the article from which I started the article on Universal Analytics event tracking. It seems the oldschool method works until the tracking code is replaced with the new Universal Analytics tracking code. Here is the article from Google on it.

          • h3sean

            I figured as much. It would seem that it depends on the tracking code. I’m glad Google didn’t force users to upgrade it universally. I’d have to hustle through all my sites just to fix all my events tracking code.