The Blog

Advanced Google Analytics E-Commerce Tracking – Just in Time for the Holidays!

shoppingcartbug

If you’re an e-commerce business using Google Analytics, chances are you’ve already installed e-commerce tracking. At a basic level, e-commerce tracking is great because it allows you to see your online revenue right in Google Analytics, where you can segment it by campaign, by region, etc. However, most people simply do the standard e-commerce implementation and leave it at that. Today, I want to show you an easy way to make Google’s e-commerce tracking far more actionable. 

Conceptually, tracking transactions in Google Analytics ultimately comes down to executing the _trackTrans() method. What this means is that you can actually tell Google Analytics to record a “transaction” anywhere you want! Most people, of course, record transactions after a successful transaction actually occurs on their website. To take your e-commerce tracking to the next level, though, we’ll need to get beyond that. Instead of just seeing how much revenue you’ve earned in a day, what your top products are, etc., it’s vastly more helpful to know how much revenue you missed in a day. That’s your optimization opportunity! Which products were frequently added to your shopping cart, for example, but then not purchased? How much of the “revenue” that was added to your shopping cart actually ended up being real revenue in your pocket? These are the kinds of questions I’ll show you how to answer with a quick tweak to your Google Analytics setup.

What you’ll need to do is record transactions any time a user adds a product to his/her shopping cart. (If that sounds weird, don’t forget: as long as you execute Google’s e-commerce tracking code, you can record a transaction wherever you want!) However, you’ll need to record these add-to-cart transactions using a different Google Analytics property ID. So, if you’re doing your primary tracking with UA-XXXXX-Y, you’ll need to record your new add-to-cart transactions with UA-XXXXX-Z. Aside from that, however, your implementation of the e-commerce code for add-to-cart transactions will be essentially the same as your initial implementation of e-commerce tracking!

Here’s a quick example of the e-commerce tracking code you’ll execute when someone adds a product to your shopping cart:

_gaq.push(['_setAccount', 'UA-XXXXX-Z']); // Update UA-XXXXX-Y to UA-XXXXX-Z!
_gaq.push(['_addTrans',
'1234',           // order ID - required
‘Example Store',  // affiliation or store name
‘26.00',          // total - required
'1.00',           // tax
'5.00',              // shipping
'San Francisco',       // city
'California',     // state or province
'USA'             // country
]);
_gaq.push(['_addItem',
'1234',           // order ID - required
‘SKU123',           // SKU/code - required
‘ExampleProduct',        // product name
‘Category1',   // category or variation
'10.00',          // unit price - required
‘2'               // quantity - required
]);
_gaq.push(['_trackTrans']); //submits transaction to the Analytics servers

As you can see, this is the same as a “normal” e-commerce implementation, but you’ve used _setAccount to flip your GA tracking ID from UA-XXXXX-Y to UA-XXXXX-Z. Of course, don’t forget to create a Google Analytics profile with the ID of UA-XXXXX-Z!

The end result is that you’ll have two Google Analytics profiles containing e-commerce data: one with “real” transactions, and one with add-to-cart transactions. Now you can dig into the juicy analysis. Either through the API or manually, you can start to compare things like SKU, Product Categories, or Product Names. For example:

  • Which products (or categories of products) have a high “completion rate?” In other words, which products are rarely abandoned after being added to the cart?
    • Could you feature these on the homepage, or make them part of an upsell?
  • Conversely, which products have a high “abandonment rate?”
    • Are these products available elsewhere for a lower price?
    • How much revenue are you losing on other products due to losing these transactions?

As you can see above, by combining the transaction metrics from your two profiles, you’ll now easily be able to see not just your revenue, but your revenue opportunity. For example, on the left, I can see that while my conversion performance for Gala Apples is fanastic, I’m really struggling with Russet Potatoes. On the right, I’m comparing entire product categories. Here, I can see that I’m doing great with the Vegetables category, but not nearly as well with Canned Goods.

I hope you’ll take advantage of this kind of analysis before the holiday rush is over! If you have questions, feel free to leave them in the comments, or tweet to us @CardinalPath.

This entry was posted in Technology, Web Analytics and tagged , , . Bookmark the permalink.
  • http://twitter.com/anilopez Ani Lopez

    In countries where decimals are marked with ‘,’ comma instead of ‘.’ dot (take a look here http://en.wikipedia.org/wiki/File:DecimalSeparator.svg) is not an strange mistake to use comma for unit price, total, tax, shipping decimals what makes the numbers a complete mess.

    Double check!

  • http://twitter.com/webanalytiker Jacob Kildebogaard

    Great suggestion and use of ecommerce tracking. Another solution, with all data in the same account, is to use event tracking. Track the full funnel “Product view”, “Add To basket” and “Sale”. With the new extra “True” condition to event tracking it is now possible to do this without it makes the bouncerate wrong. Even the product price can be tracked with event tracking.

  • http://www.econtrolling.de Markus Vollmert

    Good Job :) And you can even automate the Excel comparison using an Analytics Plugin for Excel.

  • http://www.econtrolling.de Markus Vollmert

    Good Job :) And you can even automate the Excel comparison using an Analytics Plugin for Excel.

  • http://www.cxfocus.com Tim Leighton-Boyce

    I really like this approach and I’m already thinking of other ways of using it. In my mind there are considerable benefits to using the dual tracking as opposed to events, for example all the standard ecommerce reports will work as normal. Everything will be familiar to the merchandising team.

    But I can also see that the need to either swap between profiles, or use the API (or downloads) and an external solution to combine data will also be a considerable disadvantage for many.

  • http://twitter.com/TechPad Matt Clarke

    This is a very interesting idea, Nick. I’ve never thought of using ecommerce tracking in this way before. Using multiple ecommerce tracking sections could also be a neat way of doing roll-up ecommerce reporting, for those of us operating several related sites. 

    Do you think it provides any real benefits over the usual event tracking method, though? I’ve usually achieved this by adding a _trackEvent() like this: _gaq.push([‘_trackEvent’,’add to basket’,’Product name’,’SKU1234′,37]); which I think (without having tested your method) might provide similar data.

    This allows me to see the total number of items added to baskets, the conversion rate for those products added, the value of the items added, and various other things. Using advanced segments you can also see how many baskets were started and not purchased, giving approximate calculations on abandoned basket values. The obvious benefit, as Tim mentions, is that you don’t need to switch profiles to see both sets of data. 

    • http://www.cardinalpath.com Nick Iyengar

      Hi Matt, thanks. I do think this method offers some advantages over using event tracking to record e-commerce data as you mentioned. First, it’s difficult to pass as much information to GA via an event as it is via a transaction with items. In the example you gave, for instance, I can see Product Name, SKU, and Total Price (unless that doesn’t include tax/shipping). With the true e-commerce methods, I can also record Product Category, Affiliation, Tax, Shipping, Quantity, etc. For a lot of e-commerce sites, that’s a pretty big advantage. Second, as Tim and Markus mentioned, it’s helpful to be able to use the standard GA e-commerce reports and get simple automations via an Excel plugin like NextAnalytics.

      Thanks again for reading!

  • k3nn3dy

    Great post Nick – just what I was looking for! One question though, how do I create a GA profile using U-XXXXX-Z if my web property is using U-XXXXX-Y? many thanks 

  • JK

    What are you sending to Analytics as far as transaction data in the add to cart profile? You wouldnt have an order number, total, city, state, etc..? 

  • http://twitter.com/EsbenRasmussen Esben Rasmussen

    I can see that this potentially is very valuable data you get – BUT just as JK I have to ask, how would you practically implement this?

    How would you keep track of the order? If a user puts product A into the basket then navigates, then product B, a bit of searching then product C and then finally begins the checkout process – how would this be tracked?

    The way I see it, you can either:
    1) Track all products put into the basket as individual orders (order id could be a timestamp) – which means all orders tracked this way only consist of one product (no matter the actual qantity or different kinds of products in the basket)
    2) Use variables to remember products and their quantities. These products are then submitted as one order with one order id (e.g. a timestamp) when the user begins the checkout – BUT by doing this you won’t be able to see data from the users that simply left the website before reaching the checkout.

    Please do let me know, if you have some nifty workaround I haven’t considered.

    • http://twitter.com/EsbenRasmussen Esben Rasmussen

      Nevermind – just recalled that GA actually handles this situation. Basically you just create an orderID per session and keep on adding the products in the cart… If the products added are already registered with their SKU the data will be overwritten,

  • Pistol2000

    Thanks a lot for this article, it was really helpful.

    My question is, what do you do if, at the time of adding an item to the basket, you do not know the final orderID?

    My orderID is assigned on the final confirmation page. So if I generated and assigned a unique ‘temp’ orderID for the purposes of tracking additions to that basket, how would I ultimately tie that temp orderID to the final orderID?

    • http://twitter.com/EsbenRasmussen Esben Rasmussen

      Personally I don’t bother tying them together. It is just as valuable merely knowing which products are added to the basket and which products are bought. Comparing these data will let you see, on an overall product level, which products are underperforming.

  • http://twitter.com/alexg8rown AB Analytics

    Hi Nick,

    Late to the party here but, I like the adaptation of e-commerce tracking used here although, it does seem a bit like using a hammer to crack a nut.

    As only an approximate value for lost opportunity is sought, wouldn’t event tracking be slightly easier?

    For example…

    ‘_trackEvent’, ‘Basket Add’, ‘Product Category’, ‘Product Name’, ‘Item Value’, ‘Non-Interaction’

    onClick=”_gaq.push([‘_trackEvent’, ‘Basket Add’, ‘Fruit’, ‘Bosc Pear’, 29*, false]);”

    *Whist it isn’t possible to put decimal places in the value field (e.g. $29.99) these can be rounded up or down as appropriate.

    Similarly, the event could be used for when a visitor removes an item from their basket to observe the net affect.

    onClick=”_gaq.push([‘_trackEvent’, ‘Basket Remove’, ‘Fruit’, ‘Bosc Pear’, 29, false]);”

    There are pro’s and con’s to both approaches regarding accuracy but, this may be simpler for some users to get to grips with.

    What do you think?

Copyright © 2014, All Rights Reserved. Privacy and Copyright Policies.