Blog

+ Free advice and other musings

How to Set Up Event Tracking in Google Analytics

by | Oct 2, 2012 | Google Analytics

Event Tracking in Google Analytics

Google Analytics’ Event Tracking is a great tool for monitoring activities on your site that aren’t related to a specific URL destination.

Whereas Google Analytics typically tracks activities on your site related to page loads, Event Tracking tracks actions where no URL destination is recorded, such as clicks on social media links or PDF downloads.

How to Install Event Tracking

Before you can add Event Tracking to your site, you need to make sure that you’re using the new Asynchronous Google Analytics tracking code.

The biggest difference is that the new code is placed at the top of your page, just before the closing </head> tag in your HTML file, whereas the traditional code is placed at the bottom of your page, just before the closing </body> tag.

If you’re not using the new code, here’s how to install it.

If you have a large site with a lot of events to track, you’ll need to install the Event Tracking code in the <head> section of your site. To do this, read Google’s Guide to installing Event Tracking.

For a smaller site, however, you can insert the HTML directly onto your page within the link. The formula is:

<a href=“http://www.url.com” onClick=“_gaq.push([‘_trackEvent’, ‘Category’, ‘Action’]);” target=“_blank”>Name of Your Link</a>


1. How to Track Social Media Links
Here is how you can track links to your social media profiles or other websites that you link to.

This link:
<a href=“https://www.facebook.com/facebookpagename” target=“_blank”>Follow us on Facebook</a>

Becomes:
<a href=“https://www.facebook.com/facebookpagename” onClick=“_gaq.push([‘_trackEvent’, ‘Follow’, ‘Facebook’]);” target=“_blank”>Follow us on Facebook</a>

When people click on this link, it will show up in Analytics under Content > Events. “Follow” will be your Event Category and “Facebook” will be your Event Action.


2. How to Track PDF Downloads
If you have white papers or registration forms on your site, here’s how to track the number of times they are downloaded.

This link:
<a href=“http://url.com/registration-form.pdf” target=“_blank”>Download the registration form.</a>

Becomes:
<a href=“http://url.com/registration-form.pdf” onClick=“_gaq.push([‘_trackEvent’, ‘Download’, ‘Registration Form’]);” target=“_blank”>Download the registration form.</a>

When people click on this link, it will show up in Analytics under Content > Events. “Download” will be your Event Category. “Registration Form” will be your Event Action.


2. How to Track Member Sign Up via a Popup Window
If you use popup windows on your site, here’s how to track activity within them, such as member sign up, member sign in or contest entry submission.

Within the form action code, you will have something like this:
<input type=“submit” name=“LoginButton” class=“submit” id=“sign_in” value=“Sign Up” />

And you’ll change it to this:
<input onClick=“_gaq.push([‘_trackEvent’, ‘Join’, ‘Sign Up’, ‘linkURL=homepage’]);” type=“submit” name=“LoginButton” class=“submit” id=“sign_in” value=“Sign Up” />

This means that the button for “Sign Up” has extra code behind the scenes that says on clicking the button, tell analytics that an event occurred in the category called “Join”, and that event action was a “Sign Up” submission. Label that entry as coming from the “homepage”.

image

So if you have sign up across multiple pages, you could track what exact page the visitor was on when they signed up. But, if the sign up pop-up is only accessible from a single page, you can remove ‘linkURL=homepage’ from the code.

When people click on the sign up button, it will show up in Analytics under Content > Events. “Join” will be your Event Category. “Sign Up” will be your Event Action.


Once you have Event Tracking set up, if any of the actions you’re tracking are related to business goals, you should have them listed as conversions in the Goal section of Google Analytics.

And don’t forget, you can set up Events as Goals in Google Analytics.

 

By Crissy Campbell

Crissy was Boxcar Marketing’s project manager from May 2009 to December 2012. She handled much of our day-to-day business, including working with clients directly on editorial calendars, weekly online activity plans, social media training and outreach opportunities. Crissy holds a Master of Publishing degree and before Boxcar Marketing, she worked at the Fraser Valley Regional Library where she specialized in the development and execution of promotional campaigns to drive traffic to regional library locations. Fun Facts Crissy has seen the sun rise on the Mekong River. She took Japanese in high school. She could beat adults at Memory when she was 5. Crissy loves wine and board games. Together when possible.

You may also like …

Analytics for the Holidays

Analytics for the Holidays

Reporting on 2023 with GA4 Black Friday is upon us and soon enough the December holiday rush will become the quiet panic of 2024 as you build your first holiday report using GA4. Here's what I would do. Top Landing Pages Know where people started their journey on your...

read more