Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Shopify theme published with missing tracking or broken cart

OPS-265High impactDetectedBy FunnelGuardPublished Updated
On this page

What this issue is

In Shopify, a theme controls how your storefront looks and which code runs on each page. Many stores add tracking by pasting snippets into theme.liquid or other theme files, and add cart features through theme sections or scripts. These edits belong to one theme only.

When you publish a different theme, or a duplicate that was made before the edits, that code is gone. The new theme can also have its own cart type (drawer or page) that works differently. The store still looks fine, but pixels no longer fire or the cart no longer works.

Where a theme change breaks the funnel
  1. Ad clickVisitor lands on product page
  2. Add to cartNew theme cart script fails or button does nothing
  3. CheckoutNever reached
  4. Purchase trackingNo sale, no conversion sent

The storefront looks normal, but the break happens after the theme goes live.

Why it costs you leads or sales

A broken cart stops sales directly. Missing tracking is quieter: orders still come in, but Google Ads, Meta and others stop receiving conversions. Smart bidding then learns from less data, reports show a sudden drop, and you may cut campaigns that were actually working.

Daily orders around a theme publishExample numbers
Daily orders around a theme publish (example)Day before: 24 orders; Publish day: 11 orders; Next day: 3 orders; After fix: 23 orders09182411323Day beforePublish dayNext dayAfter fixorders

Example: illustrative numbers for a store whose add-to-cart button broke after publishing a new theme.

How to check if your site has it

Check a published or preview theme
  1. Run a real add-to-cart

    On desktop and mobile, add a product, open the cart, change the quantity and go to checkout. Watch for buttons that do nothing or a cart that stays empty.

  2. Check the browser console

    Open developer tools (F12), then the Console tab, and repeat the add-to-cart. Red JavaScript errors point to broken theme or app scripts.

  3. Look for your tracking code

    View page source and search for your GA4 ID (G-XXXX), Google Ads ID (AW-XXXX), Meta pixel ID or GTM container (GTM-XXXX). No match means the snippet is missing.

  4. Watch the network requests

    In the Network tab, filter by collect, gtm or facebook while you browse and add to cart. Missing requests mean tags are not firing.

  5. Compare themesShopify

    In Online Store > Themes, open the old theme's menu, choose Edit code, and look at theme.liquid, snippets and any custom files. Compare to the new theme, or use the Compare option in the code editor if available.

How to fix it

Restore tracking and the cart by platform
  1. Find what the old theme had

    In Online Store > Themes > old theme > Edit code, open layout/theme.liquid and look in the head and before the closing body tag for pasted scripts. Note custom snippets and sections too.

  2. Copy the code into the new theme

    Paste each snippet into the same place in the new theme's theme.liquid. Do this on an unpublished copy first.

  3. Prefer settings over pasted code

    Where possible use Settings > Customer events or the Google & YouTube and Facebook & Instagram sales channel apps, which are not tied to a theme.

  4. Fix the cart

    Check the new theme's cart type under Theme settings > Cart. If an app adds to cart (upsells, bundles), reinstall or re-enable its theme embed under Customize > App embeds.

Example: GTM head snippet placement in layout/theme.liquidhtml
<head>
  <!-- Google Tag Manager -->
  <script>(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;j.src=
  'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
  })(window,document,'script','dataLayer','GTM-XXXXXXX');</script>
  <!-- End Google Tag Manager -->
  {{ content_for_header }}
</head>

How to confirm it's fixed

After restoring the code
  • Add to cart works on desktop and mobile, and the cart shows the right items
  • Checkout opens from the cart and from the product page
  • No red errors in the browser console during the journey
  • Page source contains your GA4, Ads, Meta or GTM IDs
  • Network tab shows tracking requests for page view and add to cart
  • GA4 DebugView or Meta Test Events shows the events arriving
  • A test order (Bogus Gateway or test mode) records a purchase once, not twice

How to prevent it happening again

A safer theme publish routine
  1. Before

    Duplicate the live theme, make changes only on the copy, and list tracking code and app embeds to keep.

  2. Preview

    Run the add-to-cart and checkout test on the preview link, with tracking checks.

  3. Publish

    Publish at a quiet time and keep the old theme unpublished as a rollback.

  4. After

    Repeat the test on the live store within minutes, and again the next day.

Move tracking out of theme files where you can (sales channel apps, Customer events, a GTM container), so a theme switch cannot remove it. Keep a short document listing every custom script and where it lives.

How FunnelGuard handles this

FunnelGuard detects this. A robot visitor runs your real journey on a schedule, such as product page, add to cart and checkout, and checks each step and the tracking hits sent to GA4, Google Ads, Meta and other platforms. After a theme change, a broken cart step or a missing tracking hit shows up as a failure. It is re-checked from a second region, then one alert goes out with a screenshot and a likely cause.

It does not stop you publishing a bad theme and it does not restore code for you. It tells you quickly that something changed. Test traffic is marked (utm_source=funnelguard, fg_test=1) and stops before payment unless your store's test mode is set up. The Free plan covers 1 site and 2 journeys with daily checks, no card needed.

Frequently asked questions

Questions people ask

Why did my tracking stop after I changed my Shopify theme?

Tracking code pasted into theme files such as theme.liquid belongs to that one theme. A new theme does not include it, so pixels stop firing. Re-add the snippets or move tracking to a sales channel app, Customer events or Google Tag Manager.

Why is add to cart not working after publishing a new Shopify theme?

Common causes are an app script or embed that was not enabled in the new theme, a JavaScript error from leftover custom code, or a different cart type. Check the browser console for errors and review Customize > App embeds.

How do I test a Shopify theme before publishing it?

Duplicate the theme, use the preview link, and run a full journey: add to cart, edit the cart, start checkout. Check page source for your tracking IDs and the Network tab for tracking requests before you click Publish.

Does publishing a new Shopify theme remove my Google Analytics?

It can. If GA4 was added by pasting code into the old theme, it is lost. If it was added through the Google & YouTube channel app or Customer events, it normally keeps working across themes.

Can I roll back to my old Shopify theme?

Yes. Old themes stay in Online Store > Themes until you delete them. Open the old theme's menu and choose Publish. Remember that any edits made to the new theme since will not be in the old one.

How do I know if my Shopify purchase tracking is firing?

Place a test order using a test gateway, then check GA4 DebugView, Meta Test Events or the Google Ads tag diagnostics. You should see one purchase event. Zero means it is missing and two means it is duplicated.

Can FunnelGuard tell me when a theme change breaks my cart?

Yes. It runs your add-to-cart and checkout journey on a schedule and checks the tracking hits. If a step fails or a hit goes missing, it re-checks from a second region and sends one alert with a screenshot and likely cause.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

How: Theme change + contracts.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.