Data Quality

Fix Duplicate Ecommerce Transactions in Google Analytics

A relatively common issue with ecommerce tracking in Google Analytics is that transactions are often counted more than once. This is not really caused by an error in Google Analytics. Rather it’s a problem in the ecommerce platforms and the tracking implementations. For the most part, Google Analytics will trust that you send valid and correct data. So it doesn’t try to correct anything. But just like it’s possible (but not allowed) to log PII (Personally Identifiable Information) in Analytics such as email addresses, it’s also possible to log the same transaction multiple times. Basically, Google Analytics will not fix duplicate ecommerce transactions for you – you’ll have to DIY.

The problems with duplicate ecommerce transactions are obvious. For one, you’ll simply be seeing too many transactions. And this will affect your ecommerce conversion rate, your sales quantity and your revenue totals as well. Your average order value will also be higher than it is in reality. You can’t trust this kind of data, and if you can’t trust your data, you risk making bad decisions. In this post, I’ll show how to find out if you have a problem in the first place, why the problem is there and how to fix it. 

Do you have duplicate transactions?

It’s really easy to find out if you have duplicate transactions. Simply create a new custom report. Select Transactions as the only metric, and select Transaction ID as the only dimension. Save and open the report. (get the final report here).

If you see any Transaction IDs at all where the number of transactions is higher than 1 then, my friend, you have duplicate transactions and need to fix it.

Fix Duplicate Ecommerce Transactions

I have seen Analytics setups where as many as 15% of all transactions were just duplicates. If just 10% or 5% of your transactions are duplicates, then you have serious data quality issues.

Where do duplicate transactions come from?

Well, they come from your website. A transaction is typically sent to Google Analytics by implementing the ecommerce tracking script on your confirmation page. Let’s say a customer browses your website, finds a great product and completes the checkout and payment. The customer then arrives on the thank you page that has an ecommerce tracking script similar to this:

ga('ecommerce:addTransaction', {
 'id': '9876',
 'revenue': '39.27',
 'shipping': '6.99',
 'tax': '2.29'
});

ga('ecommerce:addItem', {
 'id': '9876',
 'name': 'Scary Clown Costume',
 'sku': 'AB123456',
 'category': 'Halloween',
 'price': '29.99',
 'quantity': '1'
});

ga('ecommerce:send');

This is the intended behaviour, and this does not result in a duplicate transaction. But let’s say that you also send a confirmation email to the customer. And that email may contain a link to See your order here which directs the customer back to the same confirmation page. If you’re not careful, the same ecommerce tracking script will still be there and will send the same transaction to Google Analytics. And then you have your duplicate transaction.

Another example is the case when the customer arrives at the thank you page and create a bookmark for future reference. A couple of days later, the customer wonders why the package hasn’t arrived yet, and then follows the bookmark too see if he/she missed something about the delivery time. Again, it’s the same confirmation page, and the ecommerce script is fired yet again, resulting in a duplicate transaction.

You get it now, right? Put simply, the number one reason behind duplicate transactions is that customers often view the confirmation page multiple times and that the ecommerce tracking script is executed with each pageview of the confirmation page.

A quick note, though: Google Analytics will not send duplicate transactions within the same session. So if your customer for some reason refreshes the confirmation page within the same session, Analytics only logs the transaction once.

How to Fix Duplicate Ecommerce Transactions

Now that we’ve established how duplicate transactions are created, it’s time to fix it. The best and most reliable fix is to do it server-side; that is, in the ecommerce platform itself. This usually means some degree of backend coding on the website and this varies from platform to platform.

The basic premise is to load the ecommerce tracking script only if it hasn’t been loaded before. In most systems, all transactions/orders are saved in a database once those orders are placed by customers. The database table will usually contain information such as the order id, date and time of the order, total revenue, the customer id etc. To fix our duplicate ecommerce transactions, we need to add an additional field (column) to flag the order as ‘tracked’ or ‘not tracked’.

Once a customer views the confirmation page, we check if the order’s tracking status is ‘tracked’ or ‘not tracked’. If the status is ‘not tracked’, then we’ll go ahead and execute the ecommerce tracking script. Likewise, if the status is ‘tracked’, we’ll do nothing and just execute a pageview without the ecommerce tracking.

Depending on the ecommerce platform, the developer’s preferences and more, there are multiple ways to go about this. But the described process should more or less be possible in most platforms, one way or the other.

Argh, I don’t have a developer!

Then you’re almost out of luck. But the reality is that many ecommerce platforms can be difficult to customise. Unless you’re using Google Tag Manager to implement your Google Analytics setup.

In that case, you need to setup a set of triggers and custom tags. Use those to prevent double submissions of transactions. I’m not providing all the, so this is not a step-by-step guide. But a working solution uses a cookie to determine if the transaction (id) has been tracked before. Then uses that information to execute the ecommerce tracking provided it hasn’t been sent before.

The drawback of using cookies is obviously that people may use different browsers and devices, and might also clear their cookies once in a while.

Summary

More often than not, duplicate transactions are not a problem. However, it’s something that I – as a consultant – run into often enough to include it in my Google Analytics audit.

The first step is to find out if you have a problem at all. Do this by using a custom report. Next, if you do have a problem, you’ll have to identify the source. The source of the problem is most often that subsequent views of the confirmation page trigger the ecommerce tracking script. In some cases, however, ecommerce tracking takes place through the Measurement Protocol. That’s an edge case, so it’s not covered in this post.

Lastly, you should – of course – take actions to fix duplicate ecommerce transactions. They pollute your data in multiple ways by affecting revenue, conversion rate, average order value and more. The best way to fix it is by doing it server-side. And the second best way to fix it is to use Google Tag Manager to setup a set of triggers and variables.

Depending on your level of coding abilities, this might be easy or really hard. If it’s too hard, get in touch and we’ll work something out.

4 thoughts on “Fix Duplicate Ecommerce Transactions in Google Analytics

  1. Hi,
    My problem is that I have a duplicate transaction with the same ID, date, hour and minute
    1. One have one affiliation name that is “Default Store View” and has a category product
    2. An the other have a different affiliation name (which is the name of the store) and doesn´t have a category product

    We did some purchases test (which doesn´t uploaded the thank page) and those were tracked as the second transaction
    We are using Google Tag Manager and Google Analytics, and the dataLayers were created with a Magento and GTM plugin

    So I´m guessing it may has notting to do with the costumer returning to the page later

    1. Hi Melina,

      It sounds like you might be sending two transactions with the same ID, but with different “content”. Google Analytics will automatically filter out duplicate transactions made in the same session – but only if they are identical. So if you send two transactions with each their affiliation, GA will not consider them identical, and will log them both.

      So in your case, you will want to check your ecommerce tracking on the confirmation page and make sure to only send one transaction (or send the two transactions to two different GA properties). Or check if your plugins or setup somehow add double tagging to your confirmation page. Contact me if you need a professional review of your setup.

Leave a Reply

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