Updated December 19, 2016

Whether or not you have the pressure of reporting revenue information to others, if you’re running an ecommerce site you should be tracking your ecommerce with Google Analytics. What the helpful articles on setting up ecommerce don’t tell you, is that if you use 3rd party shopping carts or CMS’ – setting up ecommerce can be quite a challenging task.

Google Analytics provides you with the ecommerce template that is used to pass data to the reports. What it doesn’t give you is a breakdown of the necessary pieces – what’s required and what isn’t? Before we jump into that, lets first take a look at the Google Analytics ecommerce code:

pageTracker._addTrans(“order-id”, “affiliate”, “total”, “tax”, “shipping”, “city”, “state”, “country”);
pageTracker._addItem(“order-id”, “SKU”, “product name”, “category”, “price”, “quantity”);

That’s a lot of information! 13 separate pieces of information you need about your customer and their transaction! If you use an internal or in-house shopping cart, getting the actual transaction variables to pass in should be fairly easy. But instead let’s say you’re using a 3rd party shopping cart that doesn’t offer an easy plug-in. What variables do you need to pass to this ecommerce code on the thank you page to get the data you need into Google Analytics? Let’s break down the two methods of the Google Analytics ecommerce script: the addTrans method and the addItem method.

The addTrans method really only contains two required variables, the order-id and the total. The order-id is what distinguishes this transaction as its own unique transaction within Google Analytics. If your shopping cart doesn’t give you an order-id (or transaction-id) you could always use a time stamp to differentiate your transactions.The total purchase amount is also a required field in order to see the total amount of revenue within Google Analytics.
All other variables within the addTrans method are optional.

The addItem method has three required variables: the order-id, price, and quantity. The order-id should be the same order-id used in the addTrans function. While the SKU number, product name, and category are all important – they aren’t actually required to get good data in your Google Analytics reports. The item price is required as well as the quantity, or number of items purchased.

Now, lets take another look at the ecommerce code with the required variables:

pageTracker._addTrans(“order-id”, “”, “total”, “”, “”, “”, “”, “”);
pageTracker._addItem(“order-id”, “”, “”, “”, “price”, “quantity”);

This looks much less intimidating. Most shopping carts should have this post data available for you, so with a little programming magic you should be able to get ecommerce up and running!

If you are stressing out about getting variables to track your ecommerce transactions don’t sweat it. All you need is the order-id, total transaction amount, item price, and quantity and you’re on your way to having useful ecommerce statistics within Google Analytics.