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.
- Ad clickVisitor lands on product page
- Add to cartNew theme cart script fails or button does nothing
- CheckoutNever reached
- 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.
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
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.
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.
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.
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.
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
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.
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.
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.
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.
Re-add the container
Paste the GTM head and body snippets into the new theme.liquid. Note that checkout pages use Customer events, not theme.liquid.
Check the data layer
If your tags rely on a data layer pushed by theme code (add_to_cart, view_item), copy that code too, then test in GTM Preview mode.
Diff the themes
Download both themes and compare them with a diff tool or Git. Restore every tracking and cart-related change into the new theme.
Use the Shopify CLI
Run
shopify theme devto preview changes against your store andshopify theme push --unpublishedto upload a safe copy before publishing.
<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
- 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
Before
Duplicate the live theme, make changes only on the copy, and list tracking code and app embeds to keep.
Preview
Run the add-to-cart and checkout test on the preview link, with tracking checks.
Publish
Publish at a quiet time and keep the old theme unpublished as a rollback.
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.
Related issues
- OPS-266App conflict breaking add-to-cartFix guide
- OPS-267Uninstalled app leaves broken script tagsFix guide
- OPS-268Checkout extensibility migration dropping pixelsFix guide
- OPS-269Customer events (web pixels) misconfiguredFix guide
- OPS-276Duplicate pixel via app + manual codeFix guide
- OPS-270Store password page enabledFix guide