Go to Top

Use Google Analytics to validate your shopping cart checkout

We love the Google Analytics e-commerce system, in no small part because it is so “simple”: what you see is what you get, and it can basically be used to reflect your shopping cart system’s understanding of any given transaction.

The most essential double-check comes from the fact that any given sale is made up of two independent measures: The Transaction report and the Product report.

The total revenue of these two reports, for any given time period, should be equivalent minus tax and shipping, because the value of any given Transaction should be equal to the total value of all the Products sold. Here, for example are two screen shots where the product report and the transaction report match. Since this client is running an e-commerce site whose product can be downloaded, there are no tax or shipping costs, and the two reports add up to exactly the same amount:



However, this wasn’t always so. In November our client reported some big discrepancies between the Product table and the Transaction table, as shown below:



Ouch, that is a BIG difference. It turns out that this issue happens at the level of each individual transaction, where a given transaction is set at one price point, but when you drill down into the products that make up a transaction, you get an entirely different value. Look at the transaction below, for example:



The transaction value is correct, but when looking at the transaction at the product level, the total value described for that transaction is completely wrong.

What is going on here? Well, in order to understand it, we have to go “under the hood” and look at the way that Google Analytics records transactions.

First, we conducted this transaction, trying to replicate the effect of 30 items at $49 each. I got all the way to the Thank You page and took a look at the tracking code. It looked like this:

<script type=”text/javascript”>
try {
var pageTracker1 = _gat._getTracker(“UA-xxxxxxx-x”);
pageTracker1._addTrans (
“1283533″, // Order ID
“css”, // Affiliation
“1470.00″,   // Total
“”, // Tax
“”, // Shipping
“Anytown”, // City
“AZ”, // State
“US” // Country

“1283533″, // Order ID
“1570225″, // SKU
“PRODUCT ABCD / BBY X V1.0″, // Product Name
“Download”, // Category
“1470.00″, // Price
“30″ // Quantity


catch(err) {}

The key issue in that script are highlighted in bold. What we found is that the code in our client’s ecommerce system, which generated this tracking code, was putting the TOTAL value of the items sold in that line, as opposed to the UNIT COST of that item. Since Google Analytics just accepts whatever data it gets, it doesn’t check to make sure the total price of the transaction is the same as the sum of item price times quantity.

Our client saw different numbers on different reports in Analytics because

  • the transaction report generates revenue based on the sum of transactions, while
  • the product reports bases revenue off the sum of (item price x quantity),

and neither table checks against the other. This kind of simplicity is perfect for unit testing, because the two values do need to be checked using business logic at some point, and Google Analytics does not presume to do so. After all, it is just supposed to report on what is coming out of your e-commerce platform, not comment on it.

The unit cost of this particular price is $49, and is what should have been in the “Price” line, which, if 30 items were sold, would equal $1,470. Instead, the total of the whole transaction was in the line, so the shopping cart system was telling Google Analytics that it sold 30 items at a price of $1,470 each, for a grand total of over FORTY-FOUR THOUSAND DOLLARS!

This story had a happy ending, because the transaction error was easy to fix. But it also allowed our client to do a sanity check against their other systems that required a feed from the merchant system and confirm they worked as well.

Yet another reason we appreciate Google Analytics: the system is so simple that it exposes any errors you might be pushing out from your shopping cart, as long as you take the time to look!

facebooktwittergoogle_plusredditpinterestlinkedinmailby feather
, , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>