Getting started with Google Analytics event tracking for eCommerce

Aran Reeks
By Aran Reeks
4 Nov 2013

For any eCommerce business you want to know how easy people find your site to use. You need to know where they encounter problems and the points where they are most likely to abandon their purchase.  You need this to help direct your approach to improving your site and your conversion rates.

One way to find out much of what you need to know is to set up event tracking within Google Analytics. There are some more elegant and sophisticated options for monitoring how visitors behave, but the Google Analytics event tracking approach is something that can be set up on any site if you have a bit of technical knowledge (more about the technical aspects later).

Event tracking will yield a wealth of statistics about critical events on your site so that you can identify areas of weakness such as required data not being entered correctly and why forms get abandoned. You can then make informed and targeted improvements in the form of, for example, clearer layouts, more flexible inputs and better help information.

What is an ‘event’?

Events are specific actions that you decide to measure and they can be almost anything. Common examples on eCommerce sites include discount codes being applied, form submission, and add to cart actions to name just a few.

You can also set up events to track errors. Every time that a form fails validation and the user sees an error message, event tracking can be used to log exactly which errors were reported. A significant number of visitors getting the same error in the same field would be an obvious place to look for problems. It could reveal something as simple as a confusing or unusual format for entering credit card expiry dates.

How to target event tracking

For complex eCommerce sites you might want to use the more general Google Analytics data to help you target your event tracking. Pages with a low number of completions in relation to the total visitors would be a good place to start.

You can also look at segmenting your users to get reports by user type. Is the experience of new users significantly different from returning visitors who would be more familiar with any quirky form layouts or input formats? If you have eCommerce tracking set up properly you can look at whether visitors from different sources or on different devices have unexpectedly low conversion rates; you can track events for each segment of your traffic to identify specific issues that might get lost in the overall data.

Useful events to track

Working out what to track can take a bit of thought. To help you here’s a list of common events that we track on our clients’ eCommerce sites:

  • Add to cart or wishlist. This is the most fundamental event to track. It’s the starting point for collecting data for abandoned cart emails and remarketing campaigns. Knowing how many people start a cart but fail to complete a purchase is a critical measurement of your site’s effectiveness and could indicate serious issues with your cart design or checkout process.
  • Unsuccessful add to cart or wishlist and the reason. If somebody was unable to add an item successfully you want to know why. Was it because they couldn’t work out how to select a product variation such as size or colour? It’s hard to imagine a more important issue to identify than people wanting to add an item to a cart and not being able to do so.
  • Delete from cart or wishlist. To an extent this is normal if people are using the cart or wishlist to compare prices and features. But if the rate is abnormally high perhaps people are having problems with selecting exactly the right product. This may be an event to look at if you have stubbornly low conversion rates.
  • Call to action (CTA) clicks. If people are missing your calls to action then you need to look at their size, position and prominence.  Tracking CTA clicks also helps you understand how people really move through your eCommerce site compared to how you anticipated they would.
  • Delivery method changes.  Significant numbers of changes to delivery options could indicate that the way you present the options is unclear, your prices seem unreasonable or maybe your options are just too similar and customers are unsure which one best suits them. Any of these will reduce your conversion rates.
  • Product upsell region clicks. Clearly you want to understand how effective your upselling is. Are people seeing the options and are they the most appropriate ones?
  • Search results (including the number of results returned). Understand how many people use your search facility and whether they are getting a manageable number of matches.
  • Discount code usage. This is essential if you want to track the effectiveness of your advertising and marketing campaigns, so long as you can match specific codes to specific campaigns. You also want to know if codes failed through being invalid or expired.

Event tracking also gives you a statistical picture of how people move through the sales process and where they tend to drop out. To understand this we track basic actions like the following:

  • Login/Logout
  • Registration
  • Checkout (step by step)
  • Changes to item quantities within the cart
  • eCommerce order placing

Product Lists - a segmented view of performance

Here’s a segmented example of how different product list sections are performing on one of our sites. As you can see this gives us invaluable insight into exactly how each section is performing and allows us to hone and measure them to achieve their best possible results:

Google Analytics even tracking for eCommerce websites

How to set up event tracking

Hopefully I’ve managed to convince you that event tracking offers a great opportunity for you to uncover the hard data that you need to improve the performance of your site.  I’m now going to go into a bit of technical detail about how you can set up event tracking. If you’re not technically minded it will still give you an insight into how the process works and how straightforward it should be for your website developer to set up .

Google provides some really great documentation on how you can integrate Analytics event tracking into your site - so if you want to dig any deeper than we have time for in this article you can jump into their docs later here:

https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide

Here’s what the event tracking JavaScript you’ll need to add looks like (Note that for this to work you’ll need Google Analytics set up on your site already):

_gaq.push(['_trackEvent', categoryactionlabelvaluenon_interaction]);

Now don’t panic because you’ve seen some code, what’s happening here is in fact really simple as I’ll now explain quickly for those of you who are not used to writing code.

There are 5 elements can you change here: category, action, label, value & non_interaction. These options all have their own uses as follows.

category (required)

A name you can designate to group this event within. If we were creating an event for tracking items removed from a visitor’s cart for example, I’d group these within a cart category; so for this option I’d simply enter ‘Cart’.

action (required)

This parameter allows you specify the exact action that’s being performed. Using the above example of deleting an item from my cart, I’d want to pass a value of ‘Delete from cart’ or similar words to that effect. You’re free to name these as you desire.

label (optional)

An optional text label to provide additional dimensions to the event data.

value (optional)

An optional numeric value that you can use to provide more detail about the event. On add to cart actions it would be helpful to perhaps supply the value of the item here.

non-interaction (optional)

A parameter that will only accept a value of either true or false. When set to true, the event hit will not be used in bounce-rate calculations. For almost every event you want this set to false (as it is by default) as most events are user-driven such as clicking on an add to cart button.  Even though the user may have only visited this one page it is not treated as a ‘bounce’ if they perform no other actions (such as following another a link on the page) before leaving the site.

The typical scenario where I’d set this to true would be if I had an event simply for a user scrolling far enough down a page to see a section of content. We want to track this event but there is still no explicit action - so we’d still want to track a bounce if they simply left after this event.

As keen eyed readers will have already spotted only the first 2 of these are required.

Going back to the initial example of a visitor removing an item from their cart you could make this as simple as:

_gaq.push(['_trackEvent', ‘Cart’, ‘Delete item from cart’]);

Please note that the quotes shown around the 2 parameters highlighted above are required for this to work.

Inserting the above code into your website would instantly track this goal on each page load. It would be more useful though for the event only to track when the delete from cart link is clicked. Imagine you have a link on your cart page as below for deleting an item from your cart:

Delete

All you need to do to add the event tracking onto this link is to add an onClick attribute to it with the contents being the event tracking code we just created above. A full working example of this can be found below (again note that this will require the normal Google Analytics tracking code on the same page).

_gaq.push(['_trackEvent', ‘Cart’, ‘Delete item from cart’]);” href=”/delete_from_cart”>Delete

That’s it! Well done, you’ve now successfully written and tracked your first even within Google Analytics.

We’d love to hear about any events you’re tracking already or perhaps would like to track on your website and how effective you’ve found them to be, let us know in the comments section below.