How to reverse eCommerce transactions in Google Analytics using the Measurement Protocol
How to remove cancelled/refunded transactions from Google Analytics
Data Quality is essential for Google Analytics, especially when analysing the Transactions and Sales Reports. In this article, HammaJack Data Analyst, Aayush Maggo, shares what to do when unwanted transactions enter into your Google Analytics account view and inflate your transactions, and outlines how you can remove these instances.
Let’s say a test order is placed by your development team on the site, and these test transactions are now visible in your main GA analysis view. You don’t want them there as these test transactions end up skewing your eCommerce reports. This affects the overall Data Quality of your account and makes your GA data inaccurate and unreliable.
This is a scenario that the HammaJack team came across recently for one of our clients, where a series of test conversions end up inflating the eCommerce stats.
The test conversions are a problem not just for your standard GA reports but will cause headaches when reporting from other tools such as Google Data Studio which use GA as a source for reporting.
In addition to any test conversions, you could also find yourself wanting to remove any of the following transactions from Google Analytics:
Unfulfilled or declined transactions
For simplicity’s sake I have grouped all of the above as ‘unwanted transactions’ as these will all end up causing discrepancies between your GA transaction data and the actual sales data.
In this article, I’ll be outlining all the steps required to remove unwanted transactions to make your reports accurate and trustworthy. But before we dive into the steps, let’s first understand what Google Measurement Protocol is.
What is Google Measurement Protocol?
Google Measurement Protocol is a set of rules that allows developers to send data to Google Analytics Servers from any device, so long as the device is connected to the Internet. While the GA tracking code placed on your website does this on its own, developers use the measurement protocol to send data in a format that the analytics server understands.
Every hit sent via the measurement protocol consists of two parts:
Transport: This determines how the hit is sent. For Google Analytics server, this is always the HTTPs request made to the endpoint: https://www.google-analytics.com/collect
Payload: The content of the hit that looks like a URL query parameter string. Here’s an example of what a payload looks like - v=1&t=transaction&tid=UA-XXXXXXXX-X&cid=b15d9d29-4387-4d24-b56c-9027fdf95e84
If you need a guide to learn more about the Google Measurement Protocol you can read about it here.
Utilising the measurement protocol allows us to reverse the unwanted transactions in Google Analytics.Whilst the tool is built for developers, you do not need any technical know-how to reverse transactions as long as you are following each step. With that said, let’s dive into the steps.
Steps to reverse the unwanted transactions
Step 1: Make sure that you have the ‘Edit’ permissions to your analytics account. Go to Admin < User Management to confirm.
Step 2: Navigate to your Ecommerce reports and make a note of all the transaction ID’s you want to reverse. Go to Conversions < Ecommerce < Sales Performance.
Step 3: Once the transaction ID’s are listed, go to the measurement protocol builder site.
You will find a bunch of parameters here that will build the payload for our hit. There are hit types represented by ‘t’, version (v), tracking id (tid) and client id (cid)
Stick with the default version (v) set as 1, and change the hit type (t) to a transaction.
Step 4: Add your tracking id/web property id (tid) and generate a random client id.
Here’s what your basic set of parameters should look like;
Step 5: With the basic parameters covered, we’ll add a bunch more to include information for the transactions we want to remove.
Use the ‘Add Parameter’ button to add the following parameters and populate these with the transaction values;
Transaction ID (ti) - Required
Transaction Revenue (tr)
Transaction Shipping (ts)
Transaction Tax (tt)
Item Quantity (iq)
Campaign Source (cs)
Campaign Medium (cm).
Here’s what the parameter fields should look like:
Few things to note here:
Of the added parameters, only the transaction id is required to successfully send over the hit. However, as the goal is to reverse/remove the unwanted transactions, adding all the possible transaction details here including the transaction revenue, tax and shipping details will ensure that you successfully remove not only the transaction hit, but also update other reports that rely on eCommerce reporting.
Add the revenue, tax and shipping value with a negative sign as displayed in the screenshot above.
The above parameters should suffice for successful removal. If any of these values are not set, feel free to omit from the list.
Feel free to also add more information about the transaction. You can find the complete list of transaction parameters here.
Step 6: Validate and send the hit
On successful validation, click on ‘Send hit to Google Analytics’.
Step 7: Wait 15-20 minutes (it can take up to an hour) for the hit to be populated onto your Google Analytics view. Confirm the successful hit by navigating back to Sales Performance Report (Conversions < Ecommerce < Sale Performance).
Those are the complete list of steps required to successfully reverse the unwanted transactions. Please note that it is important to make the reverse transaction as soon as you are aware of it. You won’t see the test transaction if the reverse transaction is sent on the same day. However, if there is a delay of a day or more between the test and reverse transaction, Google Analytics will have two transactions (the original transaction and the reverse transaction).
Choose a duration of analysis to include the test and reverse transaction to stop the transaction from appearing.
Bonus free template
You can follow the above steps or simply grab our free hit builder Google Sheet and just follow the easy instructions. The hit builder sheet lists all the parameters you need to successfully reverse the transaction. Simply add the transaction values and copy your transaction hit.
Most Important Point
The last thing you want when analysing your eCommerce data in Google Analytics is to have unwanted transactions enter into your Google Analytics account view, as this can skew your data and even make your account unreliable and untrustworthy. Thankfully you can remove these unwanted conversions (such as test or cancelled transactions), and if you use these steps as soon as you spot an unwanted transaction you can remove it with ease and continue to keep your data and reporting as clean and reliable as possible.