{"id":12,"date":"2023-03-09T09:35:00","date_gmt":"2023-03-09T09:35:00","guid":{"rendered":"https:\/\/www.getmesa.com/blog\/2020\/07\/10\/how-to-automatically-record-100-of-shopify-refunds-in-google-analytics\/"},"modified":"2025-12-22T23:36:39","modified_gmt":"2025-12-22T23:36:39","slug":"how-to-track-shopify-refunds-in-google-analytics","status":"publish","type":"post","link":"https:\/\/www.getmesa.com/blog\/how-to-track-shopify-refunds-in-google-analytics\/","title":{"rendered":"How to Track Refunds in Google Analytics"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In this tutorial, we&#8217;ll show you how to track refunds from Shopify orders into Google Analytics so your data is always accurate. Google Analytics is a great reporting tool for Shopify stores because it lets you track visitors, sessions, and other <a href=\"https:\/\/www.getmesa.com\/blog\/11-ecommerce-metrics-shopify-store-owners-need-to-track\/\">ecommerce metrics<\/a> for customer behavior like order transactions. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, there is a big problem that Shopify merchants encounter when using Google Analytics: it&#8217;s missing order refunds and returns.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Historically, getting refunds from Shopify orders to show up in Google Analytics was&nbsp;<a href=\"https:\/\/support.google.com\/analytics\/answer\/6014861?hl=en\" target=\"_blank\" rel=\"noreferrer noopener\">a manual job<\/a>. It is a method that is time-consuming, prone to human error, and results in a lack of real-time data.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s where&nbsp;MESA&nbsp;comes in. By automating this workflow, you can create real-time reversal transactions in Google Analytics. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s take a look at how out how it\u2019s done.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-cyan-bluish-gray-color has-alpha-channel-opacity has-cyan-bluish-gray-background-color has-background is-style-dots\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>TL;DR: Skip the step-by-step tutorial.&nbsp;<\/strong>Use this template to track refunds in Google Analytics with just a few clicks.<\/p>\n\n\n<div class=\"mesa-template-backend frontend-hidden\">\n    <p><strong>MESA Template ID<\/strong><\/p>\n    <p>track-shopify-refunds-in-google-analytics<\/p>\n<\/div>\n\n<div class=\"mesa-template\" data-template=\"track-shopify-refunds-in-google-analytics\"><\/div>\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\t\t<style>.mesa-template-backend {\n    background: rgba(139, 139, 150, 0.1);\n    padding: 22px;\n}\n\n.mesa-template-backend h5,\n.mesa-template-backend p {\n    margin: 0 0 5px;\n}\n\n.mesa-template-backend p {\n    font-size: 16px;\n}\n\n.mesa-template-backend p:last-child {\n    display: inline-block;\n    background: #fff;\n    padding: 5px 10px;\n}\n\n.mesa-template-backend p strong {\n    font-size: 12px;\n}<\/style>\n\t\t\n\n\n<h2 class=\"wp-block-heading\" id=\"h-step-by-step-instructions-how-to-track-shopify-refunds-in-ga\"><span class=\"ez-toc-section\" id=\"Step-by-step-instructions-How-to-track-Shopify-refunds-in-GA\"><\/span>Step-by-step instructions: How to track Shopify refunds in GA<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<div class=\"schema-how-to wp-block-yoast-how-to-block\"><p class=\"schema-how-to-total-time\"><span class=\"schema-how-to-duration-time-text\">Time needed:&nbsp;<\/span>5 minutes<\/p><p class=\"schema-how-to-description\">Google Analytics doesn&#8217;t have an app in the Shopify App Store so sending any specific transaction events would otherwise require custom code by a developer. Instead, we&#8217;ll show you a simpler way using a simple workflow to automate the entire process.<br><br>Be sure to have the <a href=\"http:\/\/app.getmesa.com\/install\" target=\"_blank\" rel=\"noreferrer noopener\">MESA app<\/a> added to your Shopify store.<\/p> <ol class=\"schema-how-to-steps\"><li class=\"schema-how-to-step\" id=\"how-to-step-1678377149324\"><strong class=\"schema-how-to-step-name\">First, start a new workflow using the Shopify trigger step called &#8220;Refund Created&#8221;<\/strong> <p class=\"schema-how-to-step-text\">When making a new workflow, simply click the Shopify app then use the search field to reveal the Refund Created trigger step. Click the &#8220;Start&#8221; button to select it as the first step of your workflow.<img loading=\"lazy\" decoding=\"async\" width=\"3024\" height=\"1730\" class=\"wp-image-6467\" alt=\"shopify refund created\" src=\"https:\/\/www.getmesa.com\/blog\/wp-content\/uploads\/shopify-refund-created.png\" style=\"max-width:100%;\" srcset=\"https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-refund-created.png 3024w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-refund-created-300x172.png 300w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-refund-created-1024x586.png 1024w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-refund-created-768x439.png 768w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-refund-created-1536x879.png 1536w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-refund-created-2048x1172.png 2048w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-refund-created-1920x1098.png 1920w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-refund-created-544x311.png 544w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-refund-created-350x200.png 350w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-refund-created-752x430.png 752w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-refund-created-280x160.png 280w\" sizes=\"auto, (max-width: 3024px) 100vw, 3024px\" \/><\/p> <\/li><li class=\"schema-how-to-step\" id=\"how-to-step-1678377321912\"><strong class=\"schema-how-to-step-name\">Next, add the Shopify action step called &#8220;Retrieve Order&#8221;<\/strong> <p class=\"schema-how-to-step-text\">Add another step by selecting the Shopify app again, then search for the Retrieve Order step. Click the &#8220;Use this&#8221; button to add it to your workflow.<img loading=\"lazy\" decoding=\"async\" width=\"3024\" height=\"1730\" class=\"wp-image-6469\" alt=\"shopify retrieve order step\" src=\"https:\/\/www.getmesa.com\/blog\/wp-content\/uploads\/shopify-retrieve-order-step.png\" style=\"max-width:100%;\" srcset=\"https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-retrieve-order-step.png 3024w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-retrieve-order-step-300x172.png 300w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-retrieve-order-step-1024x586.png 1024w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-retrieve-order-step-768x439.png 768w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-retrieve-order-step-1536x879.png 1536w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-retrieve-order-step-2048x1172.png 2048w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-retrieve-order-step-1920x1098.png 1920w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-retrieve-order-step-544x311.png 544w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-retrieve-order-step-350x200.png 350w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-retrieve-order-step-752x430.png 752w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-retrieve-order-step-280x160.png 280w\" sizes=\"auto, (max-width: 3024px) 100vw, 3024px\" \/><\/p> <\/li><li class=\"schema-how-to-step\" id=\"how-to-step-1678377713077\"><strong class=\"schema-how-to-step-name\">Select the &#8220;Order ID&#8221; variable from the previous Refund Created step<\/strong> <p class=\"schema-how-to-step-text\">Click the Variable Selector to open the drawer. Click to expand the Refund Created variables and choose the Order ID from the list. This ensures we&#8217;ve got the right order details for the next steps in the workflow.<img loading=\"lazy\" decoding=\"async\" width=\"3024\" height=\"1730\" class=\"wp-image-6468\" alt=\"shopify retrieve order variables\" src=\"https:\/\/www.getmesa.com\/blog\/wp-content\/uploads\/shopify-retrieve-order.png\" style=\"max-width:100%;\" srcset=\"https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-retrieve-order.png 3024w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-retrieve-order-300x172.png 300w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-retrieve-order-1024x586.png 1024w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-retrieve-order-768x439.png 768w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-retrieve-order-1536x879.png 1536w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-retrieve-order-2048x1172.png 2048w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-retrieve-order-1920x1098.png 1920w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-retrieve-order-544x311.png 544w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-retrieve-order-350x200.png 350w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-retrieve-order-752x430.png 752w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/shopify-retrieve-order-280x160.png 280w\" sizes=\"auto, (max-width: 3024px) 100vw, 3024px\" \/><\/p> <\/li><li class=\"schema-how-to-step\" id=\"how-to-step-1678377358386\"><strong class=\"schema-how-to-step-name\">Use the built-in app, Code by MESA<\/strong> <p class=\"schema-how-to-step-text\">Add another step to your workflow, this time selecting the Code by MESA app. This is a built-in app that lets us add custom code functions between workflow steps. So we know what this step does, lets add the following as the description: &#8220;Calculates the refund amount that gets sent to Google Analytics.&#8221;<img loading=\"lazy\" decoding=\"async\" width=\"3024\" height=\"2110\" class=\"wp-image-6470\" alt=\"code by mesa step\" src=\"https:\/\/www.getmesa.com\/blog\/wp-content\/uploads\/code-by-mesa-step.png\" style=\"max-width:100%;\" srcset=\"https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/code-by-mesa-step.png 3024w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/code-by-mesa-step-300x209.png 300w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/code-by-mesa-step-1024x714.png 1024w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/code-by-mesa-step-768x536.png 768w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/code-by-mesa-step-1536x1072.png 1536w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/code-by-mesa-step-2048x1429.png 2048w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/code-by-mesa-step-1920x1340.png 1920w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/code-by-mesa-step-446x311.png 446w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/code-by-mesa-step-287x200.png 287w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/code-by-mesa-step-616x430.png 616w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/code-by-mesa-step-229x160.png 229w\" sizes=\"auto, (max-width: 3024px) 100vw, 3024px\" \/><\/p> <\/li><li class=\"schema-how-to-step\" id=\"how-to-step-1678417701104\"><strong class=\"schema-how-to-step-name\">Paste this code snippet to calculate the amount to refund<\/strong> <p class=\"schema-how-to-step-text\">Next, click the &#8220;Edit Code&#8221; link and paste the following code snippet over the existing content within the editor. Save then Close the editor afterward:<br\/><br\/><em>const Mesa = require(&#8216;vendor\/Mesa.js&#8217;);<br\/> <\/em> <em>module.exports = new class {<br\/><em> <\/em>   script = (payload, context) => {<br\/><em> <\/em>     \/\/ Loop through transactions on the refund, and total up the refund amount<br\/> <\/em>     <em>const refundPayload = context.steps[&#8216;shopify&#8217;];<br\/> <\/em> <em> <\/em>   <em>let refundAmount = 0;<br\/> <\/em> <em> <\/em>   <em>refundPayload.transactions.forEach(transaction => {<br\/> <\/em>   <em> <\/em>   <em>refundAmount -= transaction.amount;<br\/><em> <\/em>     });<br\/><em> <\/em>     \/\/ Add to payload<br\/><em> <\/em>     payload.total_refund_amount = refundAmount;<br\/><em> <\/em>     \/\/ We&#8217;re done, call the next step!<br\/> <\/em>     <em>Mesa.output.next(payload);<br\/> <\/em>   <em>}<br\/> <\/em> <em>}<br\/>}<\/em><img loading=\"lazy\" decoding=\"async\" width=\"3024\" height=\"1730\" class=\"wp-image-6471\" style=\"max-width:100%;\" src=\"https:\/\/www.getmesa.com\/blog\/wp-content\/uploads\/code-by-mesa-script.png\" alt=\"code by mesa script\" srcset=\"https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/code-by-mesa-script.png 3024w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/code-by-mesa-script-300x172.png 300w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/code-by-mesa-script-1024x586.png 1024w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/code-by-mesa-script-768x439.png 768w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/code-by-mesa-script-1536x879.png 1536w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/code-by-mesa-script-2048x1172.png 2048w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/code-by-mesa-script-1920x1098.png 1920w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/code-by-mesa-script-544x311.png 544w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/code-by-mesa-script-350x200.png 350w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/code-by-mesa-script-752x430.png 752w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/code-by-mesa-script-280x160.png 280w\" sizes=\"auto, (max-width: 3024px) 100vw, 3024px\" \/><\/p> <\/li><li class=\"schema-how-to-step\" id=\"how-to-step-1678377540744\"><strong class=\"schema-how-to-step-name\">Next, add the Google Analytics step, Create Transaction<\/strong> <p class=\"schema-how-to-step-text\">Next, add Google Analytics as the following step in your workflow. In the search bar, make sure to select &#8216;Version UA&#8217; from the options. Then, choose the &#8220;Create Transaction&#8221; step by choosing the &#8220;Use This&#8221; button.<img loading=\"lazy\" decoding=\"async\" width=\"3024\" height=\"2048\" class=\"wp-image-6472\" style=\"max-width:100%;\" src=\"https:\/\/www.getmesa.com\/blog\/wp-content\/uploads\/google-analytics-create-transaction.png\" alt=\"google analytics create transaction\" srcset=\"https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/google-analytics-create-transaction.png 3024w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/google-analytics-create-transaction-300x203.png 300w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/google-analytics-create-transaction-1024x694.png 1024w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/google-analytics-create-transaction-768x520.png 768w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/google-analytics-create-transaction-1536x1040.png 1536w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/google-analytics-create-transaction-2048x1387.png 2048w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/google-analytics-create-transaction-1920x1300.png 1920w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/google-analytics-create-transaction-459x311.png 459w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/google-analytics-create-transaction-295x200.png 295w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/google-analytics-create-transaction-635x430.png 635w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/google-analytics-create-transaction-236x160.png 236w\" sizes=\"auto, (max-width: 3024px) 100vw, 3024px\" \/><\/p> <\/li><li class=\"schema-how-to-step\" id=\"how-to-step-1678377627494\"><strong class=\"schema-how-to-step-name\">Add your Google Analytics ID, the Transaction ID and Transaction Revenue variables<\/strong> <p class=\"schema-how-to-step-text\">You need to add your Google Analytics property ID. <br\/><br\/>Then, for the Transaction ID, open the variable selector and choose, <strong>Retrieve Order > Name<\/strong> and <strong>Refund Created > ID<\/strong> with a <em>space, dash, space<\/em> in the middle as it appears in this screenshot. <br\/><br\/>Lastly, in the <strong>Transaction Revenue<\/strong> field, add the following code snippet: <br\/><br\/><em>{{custom.total_refund_amount}}<\/em><br\/><br\/>This is the refund amount calculated from our previous Code step<img loading=\"lazy\" decoding=\"async\" width=\"3024\" height=\"3712\" class=\"wp-image-6473\" alt=\"google analytics variables\" src=\"https:\/\/www.getmesa.com\/blog\/wp-content\/uploads\/google-analytics-create-transaction-variables.png\" style=\"max-width:100%;\" srcset=\"https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/google-analytics-create-transaction-variables.png 3024w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/google-analytics-create-transaction-variables-244x300.png 244w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/google-analytics-create-transaction-variables-834x1024.png 834w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/google-analytics-create-transaction-variables-768x943.png 768w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/google-analytics-create-transaction-variables-1251x1536.png 1251w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/google-analytics-create-transaction-variables-1668x2048.png 1668w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/google-analytics-create-transaction-variables-1920x2357.png 1920w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/google-analytics-create-transaction-variables-253x311.png 253w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/google-analytics-create-transaction-variables-163x200.png 163w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/google-analytics-create-transaction-variables-350x430.png 350w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/google-analytics-create-transaction-variables-130x160.png 130w\" sizes=\"auto, (max-width: 3024px) 100vw, 3024px\" \/><\/p> <\/li><li class=\"schema-how-to-step\" id=\"how-to-step-1678377563535\"><strong class=\"schema-how-to-step-name\">Save, then turn On your automation<\/strong> <p class=\"schema-how-to-step-text\">Be sure to add a contact email address to receive real-time notifications about your workflow.<br\/><br\/>We always recommend <a href=\"\/features\/workflow-testing\">testing your workflows<\/a>. Your transactions will then be found in Google Analytics under Conversions > Ecommerce > Sales Performance.<img loading=\"lazy\" decoding=\"async\" width=\"3024\" height=\"1730\" class=\"wp-image-6474\" style=\"max-width:100%;\" src=\"https:\/\/www.getmesa.com\/blog\/wp-content\/uploads\/workflow-enabled.png\" alt=\"workflow enabled\" srcset=\"https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/workflow-enabled.png 3024w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/workflow-enabled-300x172.png 300w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/workflow-enabled-1024x586.png 1024w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/workflow-enabled-768x439.png 768w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/workflow-enabled-1536x879.png 1536w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/workflow-enabled-2048x1172.png 2048w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/workflow-enabled-1920x1098.png 1920w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/workflow-enabled-544x311.png 544w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/workflow-enabled-350x200.png 350w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/workflow-enabled-752x430.png 752w, https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/workflow-enabled-280x160.png 280w\" sizes=\"auto, (max-width: 3024px) 100vw, 3024px\" \/><\/p> <\/li><\/ol><\/div>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-cyan-bluish-gray-color has-alpha-channel-opacity has-cyan-bluish-gray-background-color has-background is-style-dots\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Save yourself the setup. <\/strong>Use this template instead:<\/p>\n\n\n<div class=\"mesa-template-backend frontend-hidden\">\n    <p><strong>MESA Template ID<\/strong><\/p>\n    <p>track-shopify-refunds-in-google-analytics<\/p>\n<\/div>\n\n<div class=\"mesa-template\" data-template=\"track-shopify-refunds-in-google-analytics\"><\/div>\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-track-more-accurately-with-mesa\"><span class=\"ez-toc-section\" id=\"Track-more-accurately-with-MESA\"><\/span>Track more accurately with MESA<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Your ability to make sound business decisions is only as good as the data available. Eliminate the headaches of dealing with Google Analytics and leverage an automated approach so your data is always accurate and up-to-date. To begin with, try MESA free and start adding workflows that tackle the everyday challenges of running a Shopify store.<\/p>\n\n\n\n<div class=\"card-next-steps\">\n\t<div class=\"card__content\">\n\t\t<h4>What to do next&#8230;<\/h4>\n<p>The fastest way to see automation working in your store is to start with a single workflow.<\/p>\n<ol>\n<li><a href=\"https:\/\/www.getmesa.com\/pricing\"><strong>Try MESA free<\/strong><\/a> \u2014 start a 7-day free trial and get your first workflow running.<\/li>\n<li><a href=\"https:\/\/www.getmesa.com\/templates\"><strong>Browse the template library<\/strong><\/a> \u2014 pre-built workflows for the most common Shopify automation tasks.<\/li>\n<li><a href=\"https:\/\/www.getmesa.com\/yedric\"><strong>Talk to Yedric<\/strong><\/a> \u2014 describe what you want to automate, and let our AI assistant build it for you.<\/li>\n<li><a href=\"https:\/\/www.getmesa.com\/support\"><strong>Get free workflow setup<\/strong><\/a> \u2014 MESA&#8217;s team will build your first workflow at no cost.<\/li>\n<\/ol>\n\t<\/div><!-- \/.card__content -->\n\n\t\n<div class=\"socials card__socials\">\n\t<ul>\n\t\t\t\t\t<li>\n\t\t\t\t<a href=\"https:\/\/twitter.com\/getmesa\" target=\"_blank\">\n\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/twitter-icon.svg\" class=\"attachment-small size-small\" alt=\"icon: twitter\" \/>\t\t\t\t<\/a>\n\t\t\t<\/li>\n\t\t\t\t\t<li>\n\t\t\t\t<a href=\"https:\/\/www.youtube.com\/@getmesa\" target=\"_blank\">\n\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/youtube-icon.svg\" class=\"attachment-small size-small\" alt=\"icon: youtube\" \/>\t\t\t\t<\/a>\n\t\t\t<\/li>\n\t\t\t\t\t<li>\n\t\t\t\t<a href=\"https:\/\/www.linkedin.com\/company\/9754608\/\" target=\"_blank\">\n\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/linkedin-icon.svg\" class=\"attachment-small size-small\" alt=\"linkedin icon\" \/>\t\t\t\t<\/a>\n\t\t\t<\/li>\n\t\t\t<\/ul>\n<\/div><!-- \/.socials -->\n<\/div><!-- \/.card-next-steps -->\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we&#8217;ll show you how to track refunds from Shopify orders into Google Analytics so your data is&#8230;<\/p>\n","protected":false},"author":1,"featured_media":6475,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[48],"tags":[285,7,66],"class_list":["post-12","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-workflow-tutorials","tag-code","tag-google-analytics","tag-shopify"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Track Refunds in Google Analytics - MESA<\/title>\n<meta name=\"description\" content=\"In this tutorial, we&#039;ll show you how to track refunds from Shopify orders into Google Analytics so your data is always accurate.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Track Refunds in Google Analytics - MESA\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, we&#039;ll show you how to track refunds from Shopify orders into Google Analytics so your data is always accurate.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/\" \/>\n<meta property=\"og:site_name\" content=\"MESA\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/web.facebook.com\/mesabyshoppad\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-03-09T09:35:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-12-22T23:36:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.getmesa.com\/blog\/wp-content\/uploads\/tutorial-shopify-to-googleanalytics.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Ryan ODonnell\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@getmesa\" \/>\n<meta name=\"twitter:site\" content=\"@getmesa\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ryan ODonnell\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/\"},\"author\":{\"name\":\"Ryan ODonnell\",\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/#\\\/schema\\\/person\\\/37dc9b968192b2be49af3950022179cc\"},\"headline\":\"How to Track Refunds in Google Analytics\",\"datePublished\":\"2023-03-09T09:35:00+00:00\",\"dateModified\":\"2025-12-22T23:36:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/\"},\"wordCount\":757,\"publisher\":{\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.getmesa.com/blog\\\/wp-content\\\/uploads\\\/tutorial-shopify-to-googleanalytics.jpg\",\"keywords\":[\"code\",\"google analytics\",\"shopify\"],\"articleSection\":[\"Workflow Tutorials\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/\",\"url\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/\",\"name\":\"How to Track Refunds in Google Analytics - MESA\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.getmesa.com/blog\\\/wp-content\\\/uploads\\\/tutorial-shopify-to-googleanalytics.jpg\",\"datePublished\":\"2023-03-09T09:35:00+00:00\",\"dateModified\":\"2025-12-22T23:36:39+00:00\",\"description\":\"In this tutorial, we'll show you how to track refunds from Shopify orders into Google Analytics so your data is always accurate.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.getmesa.com/blog\\\/wp-content\\\/uploads\\\/tutorial-shopify-to-googleanalytics.jpg\",\"contentUrl\":\"https:\\\/\\\/www.getmesa.com/blog\\\/wp-content\\\/uploads\\\/tutorial-shopify-to-googleanalytics.jpg\",\"width\":1280,\"height\":720,\"caption\":\"tutorial shopify to google analytics\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Track Refunds in Google Analytics\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/\",\"name\":\"MESA\",\"description\":\"Discover how to automate your Shopify growth\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/#organization\",\"name\":\"MESA - AI automation Platform\",\"url\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.getmesa.com/blog\\\/wp-content\\\/uploads\\\/mesa-shoppad.jpeg\",\"contentUrl\":\"https:\\\/\\\/www.getmesa.com/blog\\\/wp-content\\\/uploads\\\/mesa-shoppad.jpeg\",\"width\":225,\"height\":225,\"caption\":\"MESA - AI automation Platform\"},\"image\":{\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/web.facebook.com\\\/mesabyshoppad\\\/\",\"https:\\\/\\\/x.com\\\/getmesa\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/shoppad\\\/\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCqsf_WhcGEsZMvms1idivyw\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/#\\\/schema\\\/person\\\/37dc9b968192b2be49af3950022179cc\",\"name\":\"Ryan ODonnell\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/62bb965c979cc1de4c6f046fb47a28a57bc194da441ebe43b3dfbe2f2f893563?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/62bb965c979cc1de4c6f046fb47a28a57bc194da441ebe43b3dfbe2f2f893563?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/62bb965c979cc1de4c6f046fb47a28a57bc194da441ebe43b3dfbe2f2f893563?s=96&d=mm&r=g\",\"caption\":\"Ryan ODonnell\"},\"sameAs\":[\"https:\\\/\\\/www.getmesa.com\"]},{\"@type\":\"HowTo\",\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/#howto-1\",\"name\":\"How to Track Refunds in Google Analytics\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/#article\"},\"description\":\"Google Analytics doesn't have an app in the Shopify App Store so sending any specific transaction events would otherwise require custom code by a developer. Instead, we'll show you a simpler way using a simple workflow to automate the entire process.&lt;br>&lt;br>Be sure to have the &lt;a href=\\\"http:\\\/\\\/app.getmesa.com\\\/install\\\" target=\\\"_blank\\\" rel=\\\"noreferrer noopener\\\">MESA app&lt;\\\/a> added to your Shopify store.\",\"totalTime\":\"P0DT0H5M\",\"step\":[{\"@type\":\"HowToStep\",\"url\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/#how-to-step-1678377149324\",\"name\":\"First, start a new workflow using the Shopify trigger step called \\\"Refund Created\\\"\",\"itemListElement\":[{\"@type\":\"HowToDirection\",\"text\":\"When making a new workflow, simply click the Shopify app then use the search field to reveal the Refund Created trigger step. Click the \\\"Start\\\" button to select it as the first step of your workflow.\"}],\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/#schema-image-b58a8b56c4576e3fb3773dfb940f87c6\",\"url\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/wp-content\\\/uploads\\\/shopify-refund-created.png\",\"contentUrl\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/wp-content\\\/uploads\\\/shopify-refund-created.png\"}},{\"@type\":\"HowToStep\",\"url\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/#how-to-step-1678377321912\",\"name\":\"Next, add the Shopify action step called \\\"Retrieve Order\\\"\",\"itemListElement\":[{\"@type\":\"HowToDirection\",\"text\":\"Add another step by selecting the Shopify app again, then search for the Retrieve Order step. Click the \\\"Use this\\\" button to add it to your workflow.\"}],\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/#schema-image-9f32af0d6db9d5631b9e8946b46c8133\",\"url\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/wp-content\\\/uploads\\\/shopify-retrieve-order-step.png\",\"contentUrl\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/wp-content\\\/uploads\\\/shopify-retrieve-order-step.png\"}},{\"@type\":\"HowToStep\",\"url\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/#how-to-step-1678377713077\",\"name\":\"Select the \\\"Order ID\\\" variable from the previous Refund Created step\",\"itemListElement\":[{\"@type\":\"HowToDirection\",\"text\":\"Click the Variable Selector to open the drawer. Click to expand the Refund Created variables and choose the Order ID from the list. This ensures we've got the right order details for the next steps in the workflow.\"}],\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/#schema-image-e47bd7a66c4580bcbc301eb075553de0\",\"url\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/wp-content\\\/uploads\\\/shopify-retrieve-order.png\",\"contentUrl\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/wp-content\\\/uploads\\\/shopify-retrieve-order.png\"}},{\"@type\":\"HowToStep\",\"url\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/#how-to-step-1678377358386\",\"name\":\"Use the built-in app, Code by MESA\",\"itemListElement\":[{\"@type\":\"HowToDirection\",\"text\":\"Add another step to your workflow, this time selecting the Code by MESA app. This is a built-in app that lets us add custom code functions between workflow steps. So we know what this step does, lets add the following as the description: \\\"Calculates the refund amount that gets sent to Google Analytics.\\\"\"}],\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/#schema-image-83d092c45b67040ecd498cfe0ed72bed\",\"url\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/wp-content\\\/uploads\\\/code-by-mesa-step.png\",\"contentUrl\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/wp-content\\\/uploads\\\/code-by-mesa-step.png\"}},{\"@type\":\"HowToStep\",\"url\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/#how-to-step-1678417701104\",\"name\":\"Paste this code snippet to calculate the amount to refund\",\"itemListElement\":[{\"@type\":\"HowToDirection\",\"text\":\"Next, click the \\\"Edit Code\\\" link and paste the following code snippet over the existing content within the editor. Save then Close the editor afterward:const Mesa = require('vendor\\\/Mesa.js');  module.exports = new class {    script = (payload, context) => {      \\\/\\\/ Loop through transactions on the refund, and total up the refund amount      const refundPayload = context.steps['shopify'];      let refundAmount = 0;      refundPayload.transactions.forEach(transaction => {        refundAmount -= transaction.amount;      });      \\\/\\\/ Add to payload      payload.total_refund_amount = refundAmount;      \\\/\\\/ We're done, call the next step!      Mesa.output.next(payload);    }  }}\"}],\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/#schema-image-9fc26db69b84519cffa796f195d4bcdd\",\"url\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/wp-content\\\/uploads\\\/code-by-mesa-script.png\",\"contentUrl\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/wp-content\\\/uploads\\\/code-by-mesa-script.png\"}},{\"@type\":\"HowToStep\",\"url\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/#how-to-step-1678377540744\",\"name\":\"Next, add the Google Analytics step, Create Transaction\",\"itemListElement\":[{\"@type\":\"HowToDirection\",\"text\":\"Next, add Google Analytics as the following step in your workflow. In the search bar, make sure to select 'Version UA' from the options. Then, choose the \\\"Create Transaction\\\" step by choosing the \\\"Use This\\\" button.\"}],\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/#schema-image-2ae58922a83cd3c6955f2eaabcba5917\",\"url\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/wp-content\\\/uploads\\\/google-analytics-create-transaction.png\",\"contentUrl\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/wp-content\\\/uploads\\\/google-analytics-create-transaction.png\"}},{\"@type\":\"HowToStep\",\"url\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/#how-to-step-1678377627494\",\"name\":\"Add your Google Analytics ID, the Transaction ID and Transaction Revenue variables\",\"itemListElement\":[{\"@type\":\"HowToDirection\",\"text\":\"You need to add your Google Analytics property ID. Then, for the Transaction ID, open the variable selector and choose, Retrieve Order > Name and Refund Created > ID with a space, dash, space in the middle as it appears in this screenshot. Lastly, in the Transaction Revenue field, add the following code snippet: {{custom.total_refund_amount}}This is the refund amount calculated from our previous Code step\"}],\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/#schema-image-eb89155ae7a6f7828f794e5fd2d431a0\",\"url\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/wp-content\\\/uploads\\\/google-analytics-create-transaction-variables.png\",\"contentUrl\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/wp-content\\\/uploads\\\/google-analytics-create-transaction-variables.png\"}},{\"@type\":\"HowToStep\",\"url\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/#how-to-step-1678377563535\",\"name\":\"Save, then turn On your automation\",\"itemListElement\":[{\"@type\":\"HowToDirection\",\"text\":\"Be sure to add a contact email address to receive real-time notifications about your workflow.We always recommend testing your workflows. Your transactions will then be found in Google Analytics under Conversions > Ecommerce > Sales Performance.\"}],\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/how-to-track-shopify-refunds-in-google-analytics\\\/#schema-image-5c9bc54f2b0abcfebba8df6fbe10b89b\",\"url\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/wp-content\\\/uploads\\\/workflow-enabled.png\",\"contentUrl\":\"https:\\\/\\\/www.getmesa.com\\\/blog\\\/wp-content\\\/uploads\\\/workflow-enabled.png\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Track Refunds in Google Analytics - MESA","description":"In this tutorial, we'll show you how to track refunds from Shopify orders into Google Analytics so your data is always accurate.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/","og_locale":"en_US","og_type":"article","og_title":"How to Track Refunds in Google Analytics - MESA","og_description":"In this tutorial, we'll show you how to track refunds from Shopify orders into Google Analytics so your data is always accurate.","og_url":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/","og_site_name":"MESA","article_publisher":"https:\/\/web.facebook.com\/mesabyshoppad\/","article_published_time":"2023-03-09T09:35:00+00:00","article_modified_time":"2025-12-22T23:36:39+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/www.getmesa.com\/blog\/wp-content\/uploads\/tutorial-shopify-to-googleanalytics.jpg","type":"image\/jpeg"}],"author":"Ryan ODonnell","twitter_card":"summary_large_image","twitter_creator":"@getmesa","twitter_site":"@getmesa","twitter_misc":{"Written by":"Ryan ODonnell","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/#article","isPartOf":{"@id":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/"},"author":{"name":"Ryan ODonnell","@id":"https:\/\/www.getmesa.com\/blog\/#\/schema\/person\/37dc9b968192b2be49af3950022179cc"},"headline":"How to Track Refunds in Google Analytics","datePublished":"2023-03-09T09:35:00+00:00","dateModified":"2025-12-22T23:36:39+00:00","mainEntityOfPage":{"@id":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/"},"wordCount":757,"publisher":{"@id":"https:\/\/www.getmesa.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/#primaryimage"},"thumbnailUrl":"https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/tutorial-shopify-to-googleanalytics.jpg","keywords":["code","google analytics","shopify"],"articleSection":["Workflow Tutorials"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/","url":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/","name":"How to Track Refunds in Google Analytics - MESA","isPartOf":{"@id":"https:\/\/www.getmesa.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/#primaryimage"},"image":{"@id":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/#primaryimage"},"thumbnailUrl":"https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/tutorial-shopify-to-googleanalytics.jpg","datePublished":"2023-03-09T09:35:00+00:00","dateModified":"2025-12-22T23:36:39+00:00","description":"In this tutorial, we'll show you how to track refunds from Shopify orders into Google Analytics so your data is always accurate.","breadcrumb":{"@id":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/#primaryimage","url":"https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/tutorial-shopify-to-googleanalytics.jpg","contentUrl":"https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/tutorial-shopify-to-googleanalytics.jpg","width":1280,"height":720,"caption":"tutorial shopify to google analytics"},{"@type":"BreadcrumbList","@id":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.getmesa.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Track Refunds in Google Analytics"}]},{"@type":"WebSite","@id":"https:\/\/www.getmesa.com\/blog\/#website","url":"https:\/\/www.getmesa.com\/blog\/","name":"MESA","description":"Discover how to automate your Shopify growth","publisher":{"@id":"https:\/\/www.getmesa.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.getmesa.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.getmesa.com\/blog\/#organization","name":"MESA - AI automation Platform","url":"https:\/\/www.getmesa.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.getmesa.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/mesa-shoppad.jpeg","contentUrl":"https:\/\/www.getmesa.com/blog\/wp-content\/uploads\/mesa-shoppad.jpeg","width":225,"height":225,"caption":"MESA - AI automation Platform"},"image":{"@id":"https:\/\/www.getmesa.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/web.facebook.com\/mesabyshoppad\/","https:\/\/x.com\/getmesa","https:\/\/www.linkedin.com\/company\/shoppad\/","https:\/\/www.youtube.com\/channel\/UCqsf_WhcGEsZMvms1idivyw"]},{"@type":"Person","@id":"https:\/\/www.getmesa.com\/blog\/#\/schema\/person\/37dc9b968192b2be49af3950022179cc","name":"Ryan ODonnell","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/62bb965c979cc1de4c6f046fb47a28a57bc194da441ebe43b3dfbe2f2f893563?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/62bb965c979cc1de4c6f046fb47a28a57bc194da441ebe43b3dfbe2f2f893563?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/62bb965c979cc1de4c6f046fb47a28a57bc194da441ebe43b3dfbe2f2f893563?s=96&d=mm&r=g","caption":"Ryan ODonnell"},"sameAs":["https:\/\/www.getmesa.com"]},{"@type":"HowTo","@id":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/#howto-1","name":"How to Track Refunds in Google Analytics","mainEntityOfPage":{"@id":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/#article"},"description":"Google Analytics doesn't have an app in the Shopify App Store so sending any specific transaction events would otherwise require custom code by a developer. Instead, we'll show you a simpler way using a simple workflow to automate the entire process.&lt;br>&lt;br>Be sure to have the &lt;a href=\"http:\/\/app.getmesa.com\/install\" target=\"_blank\" rel=\"noreferrer noopener\">MESA app&lt;\/a> added to your Shopify store.","totalTime":"P0DT0H5M","step":[{"@type":"HowToStep","url":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/#how-to-step-1678377149324","name":"First, start a new workflow using the Shopify trigger step called \"Refund Created\"","itemListElement":[{"@type":"HowToDirection","text":"When making a new workflow, simply click the Shopify app then use the search field to reveal the Refund Created trigger step. Click the \"Start\" button to select it as the first step of your workflow."}],"image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/#schema-image-b58a8b56c4576e3fb3773dfb940f87c6","url":"https:\/\/www.getmesa.com\/blog\/wp-content\/uploads\/shopify-refund-created.png","contentUrl":"https:\/\/www.getmesa.com\/blog\/wp-content\/uploads\/shopify-refund-created.png"}},{"@type":"HowToStep","url":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/#how-to-step-1678377321912","name":"Next, add the Shopify action step called \"Retrieve Order\"","itemListElement":[{"@type":"HowToDirection","text":"Add another step by selecting the Shopify app again, then search for the Retrieve Order step. Click the \"Use this\" button to add it to your workflow."}],"image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/#schema-image-9f32af0d6db9d5631b9e8946b46c8133","url":"https:\/\/www.getmesa.com\/blog\/wp-content\/uploads\/shopify-retrieve-order-step.png","contentUrl":"https:\/\/www.getmesa.com\/blog\/wp-content\/uploads\/shopify-retrieve-order-step.png"}},{"@type":"HowToStep","url":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/#how-to-step-1678377713077","name":"Select the \"Order ID\" variable from the previous Refund Created step","itemListElement":[{"@type":"HowToDirection","text":"Click the Variable Selector to open the drawer. Click to expand the Refund Created variables and choose the Order ID from the list. This ensures we've got the right order details for the next steps in the workflow."}],"image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/#schema-image-e47bd7a66c4580bcbc301eb075553de0","url":"https:\/\/www.getmesa.com\/blog\/wp-content\/uploads\/shopify-retrieve-order.png","contentUrl":"https:\/\/www.getmesa.com\/blog\/wp-content\/uploads\/shopify-retrieve-order.png"}},{"@type":"HowToStep","url":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/#how-to-step-1678377358386","name":"Use the built-in app, Code by MESA","itemListElement":[{"@type":"HowToDirection","text":"Add another step to your workflow, this time selecting the Code by MESA app. This is a built-in app that lets us add custom code functions between workflow steps. So we know what this step does, lets add the following as the description: \"Calculates the refund amount that gets sent to Google Analytics.\""}],"image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/#schema-image-83d092c45b67040ecd498cfe0ed72bed","url":"https:\/\/www.getmesa.com\/blog\/wp-content\/uploads\/code-by-mesa-step.png","contentUrl":"https:\/\/www.getmesa.com\/blog\/wp-content\/uploads\/code-by-mesa-step.png"}},{"@type":"HowToStep","url":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/#how-to-step-1678417701104","name":"Paste this code snippet to calculate the amount to refund","itemListElement":[{"@type":"HowToDirection","text":"Next, click the \"Edit Code\" link and paste the following code snippet over the existing content within the editor. Save then Close the editor afterward:const Mesa = require('vendor\/Mesa.js');  module.exports = new class {    script = (payload, context) => {      \/\/ Loop through transactions on the refund, and total up the refund amount      const refundPayload = context.steps['shopify'];      let refundAmount = 0;      refundPayload.transactions.forEach(transaction => {        refundAmount -= transaction.amount;      });      \/\/ Add to payload      payload.total_refund_amount = refundAmount;      \/\/ We're done, call the next step!      Mesa.output.next(payload);    }  }}"}],"image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/#schema-image-9fc26db69b84519cffa796f195d4bcdd","url":"https:\/\/www.getmesa.com\/blog\/wp-content\/uploads\/code-by-mesa-script.png","contentUrl":"https:\/\/www.getmesa.com\/blog\/wp-content\/uploads\/code-by-mesa-script.png"}},{"@type":"HowToStep","url":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/#how-to-step-1678377540744","name":"Next, add the Google Analytics step, Create Transaction","itemListElement":[{"@type":"HowToDirection","text":"Next, add Google Analytics as the following step in your workflow. In the search bar, make sure to select 'Version UA' from the options. Then, choose the \"Create Transaction\" step by choosing the \"Use This\" button."}],"image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/#schema-image-2ae58922a83cd3c6955f2eaabcba5917","url":"https:\/\/www.getmesa.com\/blog\/wp-content\/uploads\/google-analytics-create-transaction.png","contentUrl":"https:\/\/www.getmesa.com\/blog\/wp-content\/uploads\/google-analytics-create-transaction.png"}},{"@type":"HowToStep","url":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/#how-to-step-1678377627494","name":"Add your Google Analytics ID, the Transaction ID and Transaction Revenue variables","itemListElement":[{"@type":"HowToDirection","text":"You need to add your Google Analytics property ID. Then, for the Transaction ID, open the variable selector and choose, Retrieve Order > Name and Refund Created > ID with a space, dash, space in the middle as it appears in this screenshot. Lastly, in the Transaction Revenue field, add the following code snippet: {{custom.total_refund_amount}}This is the refund amount calculated from our previous Code step"}],"image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/#schema-image-eb89155ae7a6f7828f794e5fd2d431a0","url":"https:\/\/www.getmesa.com\/blog\/wp-content\/uploads\/google-analytics-create-transaction-variables.png","contentUrl":"https:\/\/www.getmesa.com\/blog\/wp-content\/uploads\/google-analytics-create-transaction-variables.png"}},{"@type":"HowToStep","url":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/#how-to-step-1678377563535","name":"Save, then turn On your automation","itemListElement":[{"@type":"HowToDirection","text":"Be sure to add a contact email address to receive real-time notifications about your workflow.We always recommend testing your workflows. Your transactions will then be found in Google Analytics under Conversions > Ecommerce > Sales Performance."}],"image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.getmesa.com\/blog\/how-to-track-shopify-refunds-in-google-analytics\/#schema-image-5c9bc54f2b0abcfebba8df6fbe10b89b","url":"https:\/\/www.getmesa.com\/blog\/wp-content\/uploads\/workflow-enabled.png","contentUrl":"https:\/\/www.getmesa.com\/blog\/wp-content\/uploads\/workflow-enabled.png"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.getmesa.com/blog\/wp-json\/wp\/v2\/posts\/12","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.getmesa.com/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.getmesa.com/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.getmesa.com/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.getmesa.com/blog\/wp-json\/wp\/v2\/comments?post=12"}],"version-history":[{"count":11,"href":"https:\/\/www.getmesa.com/blog\/wp-json\/wp\/v2\/posts\/12\/revisions"}],"predecessor-version":[{"id":17368,"href":"https:\/\/www.getmesa.com/blog\/wp-json\/wp\/v2\/posts\/12\/revisions\/17368"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.getmesa.com/blog\/wp-json\/wp\/v2\/media\/6475"}],"wp:attachment":[{"href":"https:\/\/www.getmesa.com/blog\/wp-json\/wp\/v2\/media?parent=12"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.getmesa.com/blog\/wp-json\/wp\/v2\/categories?post=12"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.getmesa.com/blog\/wp-json\/wp\/v2\/tags?post=12"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}