Troubleshooting

Add to Cart Tracking Not Working on Shopify

3 min read··By the TrackingCoder team
🔧

Common reasons add-to-cart tracking doesn’t fire

  1. GTM container not published - You imported the container but didn’t click Submit → Publish.
  2. GTM snippet not installed on your site - The GTM code needs to be in your site’s <head> and <body>.
  3. AJAX add-to-cart doesn’t trigger a page load - Most modern stores add items to the cart via AJAX. A Page View trigger won’t fire. You need a Custom Event or DOM listener that detects the AJAX request.
  4. Button selector changed after theme update - Theme updates often rename CSS classes. If your trigger targets .add-to-cart-btn and the new theme uses .product-add-btn, the trigger silently breaks.
  5. Product data not extractable from DOM - Your tag needs product name, price, and ID. If these aren’t in the dataLayer or in predictable DOM elements, the tag fires but sends incomplete data.
  6. Shopify themes use Fetch to POST to /cart/add - Most Shopify themes add items to the cart via a Fetch request to /cart/add.js. You need to intercept this Fetch call or listen for the cart:add CustomEvent (if the theme dispatches one).

Step-by-step debugging checklist

  1. Verify GTM is installed - Visit your site, right-click → View Page Source, search for “GTM-”. If you don’t see it, GTM isn’t installed.
  2. Check GTM Preview mode - In GTM, click Preview. Navigate your site and trigger the event. Look for your tag in the Tags Fired section.
  3. Check the trigger - If the tag shows as “Not Fired”, click on it to see which trigger conditions aren’t met.
  4. Click the add-to-cart button with GTM Preview open - Check if any event fires at all. If you see nothing, the click isn’t reaching GTM (likely AJAX). If a Click event fires but your tag doesn’t, your trigger conditions are wrong.
  5. Inspect the network tab - Open DevTools → Network, click add to cart, and look for an AJAX request to a cart endpoint (e.g., /cart/add on Shopify, ?wc-ajax=add_to_cart on WooCommerce). This confirms the add-to-cart mechanism.

Shopify-specific issues

Shopify themes add items to the cart by sending a POST request to /cart/add.js. To track this, you can intercept the native Fetch API:

Create a Custom HTML tag in GTM that wraps window.fetch and checks if the request URL contains /cart/add. On a successful response, push a dataLayer event (e.g., add_to_cart) with the product data from the request body.

Some themes also dispatch a cart:add or ajaxProduct:added CustomEvent. Check your theme’s JavaScript to see if it emits one.

How to verify it’s working

  1. Open GTM Preview/Debug mode
  2. Navigate to your site
  3. Trigger the event (click add to cart)
  4. Check the GTM debug panel - your tag should appear under “Tags Fired”
  5. Check GA4 DebugView (GA4 → Admin → DebugView) to confirm the event arrived

Still didn’t work?

Our team can help. Describe what’s happening and we’ll get back to you within 24 hours.

Still didn't work? Report this issue

Fill in the details below and our team will review it within 3-5 business days. We aren't obliged to refund - but if we genuinely can't make it work, we may credit you back. Either way, your credits remain usable on a different event or site.

No need to type https:// - we'll add it for you.

Min 20 characters (0/20).

Context automatically included: add to cart tracking on shopify

Skip the manual setup

TrackingCoder detects your CMS and plugins automatically, then generates ready-to-use tracking code. No more adapting generic tutorials - get code tailored to your exact setup in under 2 minutes.

Try TrackingCoder Free →

2 free credits on signup. No card required.