Shopify9 min read1 view

Shopify GA4 remove_from_cart tracking with GTM

Set up Shopify remove_from_cart tracking through Customer events and GTM, with the event payload, GA4 parameters and test checks.

Watch on YouTube

The short answer

Track Shopify cart removals by mapping product_removed_from_cart to a GA4 remove_from_cart tag in GTM. Googledevelopers.google.com documents an items array for ecommerce events. This guide is for store owners and implementers maintaining a custom pixel, with a development store available for testing.

  • Use product_removed_from_cart as the Shopify sourceshopify.dev.
  • Set the GTM trigger to remove_from_cart in this example.
  • If an app already sends remove_from_cart, inspect it before adding a second sender.
  • Steps and settings checked against Shopify and Google documentation on 25 October 2026.

Ask an assistant

ChatGPTClaudePerplexity

FREE AUDIT

NO LOGIN

Check what Meta and Google can count on your site

  1. Your site
  2. Crisper
  3. Meta and Google count it

Enter your website to see how good its tracking is, and whether Meta is likely restricting it.

Run a free audit

How do I track Shopify cart removals in GA4?

Test a quantity reduction and removal of a whole cart line separately. Shopify supplies the removed merchandise in cartLineshopify.dev; inspect what each storefront control emits before treating them as identical actions.

The video shows the older configuration and testing method; the written steps below use the current Google tag and Shopify Pixel Helper workflow.

Use a development store, a dedicated GTM test container and a test GA4 web stream. Shopify suggests testing pixels on a dev storehelp.shopify.com before adding them to a live store. Use page_view setup when checking the rest of this tracking setup.

How do I add the custom pixel in Shopify?

Create or extend one custom pixel under Settings > Customer events, following Shopify's setup instructionshelp.shopify.com.

1. Create the pixel in your development store

  1. Give the pixel a clear name and choose Add pixel.
  2. Review Customer privacy.
  3. Select permissions and data-sale settings that match the store's consent plan, using Shopify's settings guidehelp.shopify.com.

Done when the editor is open and those choices are recorded.

Which customer privacy settings should I use?

Use settings that match the store's consent requirements. Shopify explainshelp.shopify.com that pixels in consent-required markets run only after visitors grant the configured permissions.

2. Check permission and data-sale choices

  1. Review the choices in Customer privacy with whoever manages consent for the store.
  2. Save the settings that match that plan.

Do not select a permissive setting just to make a test event appear.

Done when the saved settings match that plan.

What code sends Shopify cart removals to GTM?

Keep the GTM loader and event subscription in the same custom pixel. Shopify's GTM tutorialhelp.shopify.com uses the head loader with its HTML script tags removed.

3. Add the loader and subscription

A callback is the function inside analytics.subscribe that runs when Shopify emits the named event.

  1. Add the code below to the pixel. If this pixel already loads your test container, append only the subscription and its logging helper.
  2. Replace GTM-EXAMPLE with the ID of a test container that only your development store loads.
  3. Save the code in the development store.
remove_from_cart.js109 lines
// Initialize the dataLayerwindow.dataLayer = window.dataLayer || [];(function (w, d, s, l, i) {  w[l] = w[l] || [];  w[l].push({ "gtm.start": new Date().getTime(), event: "gtm.js" });  var f = d.getElementsByTagName(s)[0],    j = d.createElement(s),    dl = l != "dataLayer" ? "&l=" + l : "";  j.async = true;

100 more lines of JavaScript

  • Copy and download
  • Emailed to you

Unlock this snippet

Three details, and the full code is yours

No account needed. Unlock once and every snippet on the blog opens.

We email you a copy. We may follow up on WhatsApp.

Done when the saved code contains your test container ID and the product_removed_from_cart subscription.

Shopify's payload referenceshopify.dev allows null product and variant IDs. The snippet omits a missing item_id and keeps the real item_name, which Google accepts as the item identifierdevelopers.google.com. It also omits a missing auxiliary product_id; that field holds the variant ID in this example. Keep product IDs as item_id throughout the journey. If neither a usable ID nor a name is available, the snippet skips that entry, logs a diagnostic and keeps the available event amounts. The same reference allows cartLine itself to be null; the snippet then logs a warning naming remove_from_cart and sends nothing, rather than inventing an amount. Done when a cartLine: null payload logs that warning and pushes no remove_from_cart.

Done when a local synthetic payload with a null product ID still emits remove_from_cart with the real item name and no item_id property. Repeat with a null variant ID: no blank auxiliary product_id is sent. Available amounts, numeric zero and the other item fields must stay unchanged.

Read the event payload before choosing the GTM variables. Shopify's referenceshopify.dev defines this event's fields; the table shows how this example maps them.

currency

Data Layer Variable name
ecommerce.currency
Shopify field or calculation
data.cartLine.cost.totalAmount.currencyCode

value

Data Layer Variable name
ecommerce.value
Shopify field or calculation
Sum of source line costs, before item filtering

items

Data Layer Variable name
ecommerce.items
Shopify field or calculation
data.cartLine (the changed line), mapped to GA4 items

page_location

Data Layer Variable name
page_data.url
Shopify field or calculation
context.document.location.href

page_title

Data Layer Variable name
page_data.page_title
Shopify field or calculation
context.document.title

page_referrer

Data Layer Variable name
page_data.referrer
Shopify field or calculation
context.document.referrer
Use these exact paths with the snippet in this guide.

The snippet divides each line's cost.totalAmount.amount by its quantity to obtain a unit price. Shopify's payload referenceshopify.dev defines that amount as the merchandise line cost; compare it with the test cart, including discounts.

Google's event referencedevelopers.google.com defines value as the sum of item price times quantity. The snippet uses that same calculation and preserves numeric zero amounts.

The page fields use Shopify event context. Google configuration referencedevelopers.google.com defines page_location, page_title and page_referrer; the snippet leaves browser history alone.

How do I check that Shopify sends product_removed_from_cart?

Use Shopify Pixel Helper to check product_removed_from_cart before troubleshooting GA4. Shopify's testing guidehelp.shopify.com explains how to inspect the source event and errors.

4. Check the Shopify event

  1. On the development store, connect the saved pixel.
  2. Choose Test.
  3. Remove a known quantity from a populated cart.
  4. In Pixel Helper, expand the product_removed_from_cart payload and compare the fields in the table.
  5. In the pixel's browser console context, inspect the logged remove_from_cart data-layer object.

Done when Pixel Helper shows product_removed_from_cart with a green dot and its data matches that action, and the logged object's event name and mapped values match the Shopify payload.

Which Google tag should I use?

Use the current Google tag for your test web stream. Google's setup guidesupport.google.com describes the Google Analytics destination and the alternate Google tag setup.

5. Confirm the base Google tag

Reuse the intended test stream configuration. For the alternate setup, as described in Google setup guidesupport.google.com:

  1. Choose Google tag.
  2. Enter its tag ID.
  3. Use the Initialization - All Initialization Events trigger and save.

Keep pageview setup separate from this event tag; follow the Shopify page_view guide if you need manual page context.

Done when the saved tag points to the test stream and initializes before the event tag, and the remove_from_cart tag has its own event trigger rather than an All Pages trigger.

What GTM trigger should fire remove_from_cart?

Use a Custom Event trigger, which tells GTM when to run the tag. Its Event name must match the pushed event key, as Shopify's GTM instructionshelp.shopify.com explain.

6. Create the event trigger

  1. Create a Custom Event trigger.
  2. Enter remove_from_cart exactly in Event name, with regular-expression matching off.
  3. Select All Custom Events for this exact event name and save.

Done when the saved trigger matches the remove_from_cart key in the snippet.

How do I configure remove_from_cart in GTM?

Create a Data Layer Variable for each path in the mapping table. A variable reads the value from the event object; Shopify's GTM guidehelp.shopify.com describes mapping those values into tag parameters.

7. Map the event parameters

  1. For each path in the mapping table, create a Data Layer Variable.
  2. Use Version 2support.google.com for the nested paths.
  3. Give each variable a clear label, such as DLV - page_data.url.
  4. Enter the exact field path in Data Layer Variable Name, not the display label.

Done when every parameter in the table has a matching variable.

Send remove_from_cart with a Google Analytics: GA4 Event tag, following Google's event-tag instructionssupport.google.com.

8. Save the GA4 Event tag

  1. Enter the test stream's Measurement ID.
  2. Set Event Name to remove_from_cart.
  3. Under Event Parameters, add the table's parameter names, using their Data Layer Variables.
  4. Attach the remove_from_cart trigger and save.

Done when the saved event name, destination and variable mappings match the table.

Keep items as an array of item objects, not a text string. Use the explicit parameter mappings in this guide without adding a second automatic ecommerce mapping.

How do I test remove_from_cart without changing live tracking?

Check the source event and GA4 receipt in the same test session. Google's DebugView guidesupport.google.com lets you inspect received events and their parameters.

Shopify sayshelp.shopify.com Tag Assistant's Troubleshoot tag feature is incompatible with custom pixels. Use Pixel Helper for the source and DebugView for receipt; a console log alone does not show GA4 receipt.

9. Prepare the test tag for DebugView

  1. Add debug_mode: true to this test GA4 Event tag using Google's debug instructionssupport.google.com.
  2. Save the tag.

Done when the saved test tag includes that parameter.

10. Publish the version in the test container

Changes saved in a workspace do not run yet. Google sayssupport.google.com you need to publish workspace changes to make them operational.

  1. Open the test container that only your development store loads.
  2. Select Submit, then choose Publish and Create Version.
  3. Name the version and publish.

Do not publish to a container your live store loads; move the tested setup there through your normal release process.

Done when the test container's Versions list shows your version as published and the pixel code loads that container's ID.

Shopify's Test control opens the pixel for testinghelp.shopify.com. It does not replace the GTM publication step above.

11. Run the event through the test container

  1. Open Test from the connected custom pixel.
  2. Grant the planned analytics consent.
  3. Remove a known quantity from a populated cart.
  4. Check that Pixel Helper shows product_removed_from_cart without an error.
  5. Open the test property's Admin > Data display > DebugView.
  6. Select your test device and check that remove_from_cart appears with parameters that match the source values.
  7. Repeat with a different product, quantity or page.
  8. Exercise the denied-consent path.
  9. Remove debug_mode from the finished configuration after testing.

Google sayssupport.google.com setting debug_mode to false does not disable debug mode.

Done when every check above passes, your notes show both results and whether they match the consent plan, and debug_mode is absent from the saved configuration.

What should I check after this event works?

Compare the begin_checkout guide with the same test journey. Keep the source-event and GA4 receipt notes together so another implementer can repeat the check.

When is this setup the wrong fix?

A second sender, a mismatched trigger or the wrong payload needs a different fix. Check the failing stage before adding tags.

  • Another app already sends the same event: Shopify warnshelp.shopify.com that overlapping pixels can double-count it. Identify the existing sender before adding this one.
  • The trigger uses a friendly label rather than remove_from_cart: it will not match the snippet's event key. Copy the key into the trigger.
  • Contact details are mapped into GA4 parameters: Google prohibits sending personally identifiable informationsupport.google.com such as email addresses and personal phone numbers. Map only the fields listed here, and review URLs and titles for personal data.

What changed in this guide

  • 25 October 2026: Corrected the remove_from_cart mapping, consent settings, Google tag setup and test procedure. Updated the code and completion checks; the video still shows the older method. Made test-container publication mandatory and replaced the repeated intro with the event-specific next step. Corrected nullable item IDs and added synthetic null-case completion checks without reducing event amounts.

Sources

15 sources
  1. 1Shopify source↩
  2. 2Google↩
  3. 3Shopify suggests testing pixels on a dev store↩
  4. 4Shopify's setup instructions↩
  5. 5Shopify explains↩
  6. 6Shopify's GTM tutorial↩
  7. 7Google accepts as the item identifier↩
  8. 8Google configuration reference↩
  9. 9Google's data-layer guide↩
  10. 10Google's setup guide↩
  11. 11Version 2↩
  12. 12Google's event-tag instructions↩
  13. 13Google's DebugView guide↩
  14. 14Google says↩
  15. 15Google prohibits sending personally identifiable information↩