Enhanced Ecommerce is one of the most powerful modules in Google Analytics. Here you will learn how to avoid sending duplicate transactions to Google Analytics.
Why is transaction revenue in Google Analytics not matching our back-end data? Why do I see $2.000 revenue on transaction id “123ABCDEF” instead of $200, the actual revenue amount?
Ok, you will never have a 100% match between revenue measured in Google Analytics and the data in your back-end system. There are 100+ reasons why both numbers will deviate. However, you should do your best to make Google Analytics’ numbers as accurate as possible.
In this blogpost you will learn three things:
- How to set up a custom report for spotting duplicate transaction issues.
- How to automate this analysis via the Google Analytics API.
- How to mitigate these issues via three potential fixes.
First of all, if you haven’t read them yet, you should check out the other articles in the (Enhanced) Ecommerce section.
Table of Contents
- Introduction to Duplicate Transactions
- Custom Report to Spot Issues
- Automate Duplicate Transaction Tracking
- Fix Duplicate Transactions
- Concluding Thoughts
Let’s start with an introduction to duplications transactions first.
Introduction to Duplicate Transactions
Duplicate transactions in Google Analytics refer to a single transaction that was counted two or more times in the selected time period. This overcounting of transactions can greatly skew your Google Analytics data.
It impacts many other metrics as well, some examples below:
- Product revenue
- Quantity of products sold
- Average order value
I have seen hundreds of Google Analytics accounts with Enhanced Ecommerce implemented. You don’t have to worry if the percentage of transaction IDs with duplicate transactions is below 1%. However, you should definitely investigate further if it is substantially higher.
Custom Report to Spot Issues
You can create a custom report via Customisation > Custom Reports > + New Custom Report.
The building blocks of the report (metrics and dimensions) are:
- Metrics: Transactions and Revenue (optional, but helpful for impact analysis).
- Dimensions: Transaction ID.
I recommend choosing a time frame of at least 30 days, but in some cases you might want to go for two or even three full months of data.
Sort on transactions (high to low) if not set on default. And here is the corresponding report:
You would still need to do some manual work for further impact calculations. That’s why I recommend using the Google Analytics API for deeper analysis.
Automate Duplicate Transaction Tracking
You can make a lot of calculations manually, but whenever possible I try to automate those.
Here is an example of an analysis I recently ran across 15 brands that one of my clients is responsible for (all automated):
- Overall, it looks good.
- 12 Out of 15 brands have “percentage of transaction IDs with one order” greater than 95%.
- Only three brands have a lower “score” of 93% (two brands) and 88% (one brand).
In this case I would first focus on the three brands with the lowest score and see whether there are things we can do to improve the measurements in GA.
Now the key question, how can we automate this setup?
Step 1: install and open Supermetrics in Google Sheets.
Visit this URL and scroll to Google Sheets and Supermetrics if you are unfamiliar with this tool.
Step 2: set up your query in Google Sheets.
Here is what you need to select in Supermetrics (first center your mouse on the cell where you want the query to start):
- Data source: Google Analytics.
- Select views: Google Analytics view where you want to pull the data from.
- Select dates: dates to run the query on (e.g. “Last 30 days”).
- Select metrics: Transactions and Transaction revenue (optional).
- Split by / rows: Transaction ID and # rows to fetch (make sure to set high enough to pull all Transaction ID data in Google Sheets).
- Options: try to avoid Google’s data sampling (only available if you are on a paid plan).
This is what the data might look like:
In this case we have 20 transaction IDs with each one transaction, so everything looks good in this case.
Step 3: add another sheet in Google Sheets.
Now you need to add another sheet and make some automated calculations based on the data above.
The sheet above is named “Raw Data 4” and referenced in the formulas below.
This is it! You could do this for multiple GA reporting views if needed. The higher the “% order OK” the better.
You could dive deeper if you have a lot of orders and group transaction IDs by number of transactions. Simply add more COUNTIF formulas to get this done. Also, you could make data visualizations if that works better for you.
Now it’s time to look into potential solutions to mitigate this duplicate transaction issue.
Fix Duplicate Transactions
Here are three ways to mitigate the duplicate transactions issue in Google Analytics.
Option 1
Base the transaction event trigger on someting in your back-end. It should only trigger when the actual transaction takes place. This could be after the user has entered their credit card information and completes payment. And then, the event trigger should only work once and after your system has validated the transaction.
Option 2
Make your “thank you” pages to load only once and only accessible after a visitor has completed the transaction successfully. Keeping transaction hits on the “thank you” page is ok as long as a user can see and visit the page only once. Every new attempt to access/reload this page should redirect them to a different page that contains order detail information the user is probably looking for.
Option 3
The third option is to use the customTask functionality in Google Tag Manager. Here is how it works (in short):
- If the transaction ID in the hit is found in browser storage, this customTask blocks the hit from ever being fired, this preventing the duplicated information from reaching Google Analytics.
- If the transaction ID in the hit is not found in browser storage, the customTask sends the hit to GA normally, but it also stores the transaction ID in the list of transactions that has already been recorded. Thus, it blocks any future hits with this ID from being sent.
Please read Simo Ahava’s blogpost to learn more about implementing this method.
Concluding Thoughts
Tracking transactions incorrectly in Google Analytics can greatly affect your reports and data in Google Analytics.
In this article you have learned to spot potential issues, automate the analysis and how to fix it (three different ways).
As mentioned, transaction and revenue tracking will never be 100% accurate in Google Analytics, but you should strive for the best numbers possible.
Now it’s your turn!
What are your thoughts on duplicate transactions and ways to deal with it in Google Analytics? Happy to hear your feedback!
One last thing... Make sure to get my automated Google Analytics 4 Audit Tool. It contains 30 key health checks on the GA4 Setup.
Leave a Reply