How to Import Refunded Orders in Google Analytics (+ Analyze Them!)

Learn how to import refund and order reversal data in Google Analytics for more accurate revenue by channel metrics.

Refund or cancellation data within Google Analytics is not something I’ve seen much…probably less than 5% of businesses I’ve worked with in my career either had this process in place or worked to get there.

One common trait between these companies (that had a solid GA cancellation & refund import process in place) – they ran highly successful marketing & advertising campaigns.

Granted, cancellations and/or refunds are only a fraction of ensuring business-wide data accuracy, however it was clear that decisions were made on accurate data.

The process for managing refunds in GA is largely the same for any eCommerce platform – Shopify, Magento, BigCommerce, Commerce Cloud, etc.

A few callouts:

  • There is a difference between reversing a transaction and refunding a transaction. Reversing a transaction is done by sending a negative value while refunding a transaction will populate the native refund metrics available in Google Analytics.
  • In order to import refund data via the Data Import feature in GA you need to be utilizing Enhanced eCommerce.
  • You can’t “fix” refunds that have been already imported…so be sure you test refund imports on a test view first to verify it works as expected.
  • To be safe, check reports the following day after importing data to minimize freaking out if the data looks weird a few hours after.

How to Import Refunds into Google Analytics

There are three ways to manage this:

  1. Manual CSV import into GA (say, what?! Yes, you can upload CSVs to GA)
  2. Using the measurement protocol hit builder
  3. Automating imports via API

Import via CSV

If you are refunding complete transactions then all you need is a CSV file that contains your transaction IDs like this:

Google Analytics Refund CSV

Then you’ll want to head to Google Analytics => Property Settings => Data Import => Create New Import => Refund Data:

refund data import in google analyticsThen name your import in Step 2 Data Set Details and leave your Data Set Schema in Step 3 as is (you should only see Transaction ID column) and click Done.

Your next step is to upload your CSV file in the Manage Uploads Settings of this new data import:

google analytics manage uploads data import

Once you upload your file, you should see a status screen which shows the success of your import:

ga refund upload complete

That’s it!

If you are importing partial items as part of an order (e.g. only 1 qty of an order that has > 1 qty or partial amount on a single qty) then you’ll need to configure an import with a few more columns (shown below).

partial refund import to google analytics

In your data schema details from step 3, be sure to select these fields shown in row 1 below that you’re including in your import:

ga refund partial import

Note: If you’re importing a file with partial refunds then you need to have every field completed. You can’t have one row with only transaction ID for a full refund and another row that is completed for a partial refund.

Import via Measurement Protocol

This step takes advantage of the Google Analytics Hit Builder which allows you to send your own hits to Google Analytics.

This example shows how to do it through an event hit but you can also do with a pageview hit type as well.

If you’ve never used the hit builder – it’s pretty awesome! We use it quite frequently to validate test hits we’re sending for Elevar clients pushing offline data into Google Analytics.

You can view the full list of parameters here, but here are the ones we’re showing in this refund hit example:

google analytics refund via hit builder

  • v: 1 (can’t change)
  • t: event
  • tid: this is your GA property ID
  • cid: you can use any number for this (click the little generate button on right side)
  • ec: this is the Event Category and 100% subjective.
  • ea: this is the Event Action and up to you.
  • ni: this is Non Interaction hit. It can be 0 or 1, with 1 being “True”.
  • pa: this is the Product Action we’re setting on this hit which is refund (see all available actions here
  • pr1id: this is the line item of the SKU in the order. So if you had two SKUs you were sending in a single hit then you’d have pr1id AND pr2id.
  • pr1qt: this is quantity of SKU with same application for multiple SKUs in an order.
  • dh: this is setting the hostname and is optional. The reason I included this is just in case you have a custom filter on your Google Analytics account to only include your hostname in reports. 

Once you have this completed then you can click “Validate Hit” which will verify your hit is good and give you the option to send the hit.

hit builder validation

That’s it! Once you send the hit, I’ve found it can be up to 20-30 minutes before the refunds display in GA.

To save you time, you can just copy this hit below into the hit payload shown in the above screenshot and it will create the parameter fields for you:

v=1&t=event&tid=UA-12126787-4&cid=582df885-2745-4acb-83ac-4cbd20c988de&ec=Ecommerce&ea=Refund&ni=1&ti=1011&pa=refund&pr1id=sku123&pr1qt=1&dh=getelevar.com

Automate Import Process via API

This will require some development chops, but you can set up an automated process by:

  1. Automating the process of sending hits in batches or individually via Measurement Protocol HTTP POST request (similar to previous step). Google’s documentation on this is pretty solid.
  2. Another option is to automate the process of uploading your Data Import CSV file (from the first option above) through the Management API. Here is where you can get started on this and there are a few good examples of hooking this up via Google Sheets as well (here’s one example).

How to Reverse a Transaction in Google Analytics

This is close to a refund import hit except we’re sending another transaction hit with negative values to zero out the data from the original order.

The difference from refunds is we just aren’t populating the native refund metrics in Google Analytics…I think that’s about it?!

Here is how this looks in the hit builder:

reverse transaction in google analytics

A few things to note in red:

  • Total transaction revenue, tax, and shipping are negative values.
  • Product quantity is a negative value.
  • Individual product price is a positive value.

That’s pretty much it. Validate and send your hit then wait a bit to see this show up as an additional hit for this transaction ID.

How to Analyze Reversed or Refunded Reports

If you’ve never refunded orders in Google Analytics then you might get a bit confused when reviewing your transaction reports the first time.

Remember – GA is not going to delete the original order data so depending on the date range you are viewing you might see orders you expected to be refunded like this:

Notice the revenue and refund amount columns?

Once you include the date when you imported your refund data, you should see something like this:

ga no revenue after refund

Wait…why do some of my orders have $0 revenue and others don’t?

Well in this case these orders were placed in October but my report is November – December. Once I change my date, I now see revenue here too (phew):

ga revenue refund complete

Now we can begin creating reports to slice our refund data further; like by medium:

refund by medium

Google states one caveat of viewing refund data by source/medium – if the user returns to your site after placing an order and still has their original GA cookie in place then this refund will be attributed to the last session they visited from…not the session where they completed the purchase.

Not very helpful.

I hope this quick tutorial on importing refunds to Google Analytics helps :).

Related Articles:

  1. Feature Analysis Segmentation
  2. SEO Analysis via Google Search Console 

Google Analytics Tips

Want more helpful eCommerce and Analytics tips? Join our email list.

We respect your inbox.


Brad Redding

Brad, co-founder of Elevar, has lived in eCommerce for over 12 years. He's helped design, build, and optimize over 100 websites in his career. From new retail startups to well-known brands like Le Creuset, Signature Hardware, Rebecca Minkoff, Char-Broil and more, he specializes in data analytics and conversion optimization to help achieve business goals.

Leave a Reply

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