On this page
What this issue is
A WordPress theme is a folder of files. When the theme author releases a new version, WordPress deletes the old folder and puts the new one in its place. Any edit you made inside that folder is gone.
This often hits tracking code (a GA4, Meta Pixel or Google Ads snippet pasted into header.php), custom PHP added to functions.php, CSS edits in style.css, and edited template files such as checkout or form templates. The site still looks fine, so nobody notices that tracking or a form tweak has vanished.
Why it costs you leads or sales
If the tracking snippet disappears, ad platforms stop receiving conversions. Smart bidding in Google Ads and Meta then optimises on less data, and reports show a sudden drop that looks like a demand problem. If a custom form hook or checkout edit is lost, the form or checkout may behave differently or fail.
- Theme updateOld theme folder replaced
- Custom code deletedTracking snippet gone from header.php
- Conversion eventNo hit sent to GA4 or ad platforms
- Ad optimisationBidding learns from missing data
The update itself succeeds, so the loss goes unnoticed.
Example: illustrative numbers showing reported conversions falling to zero the week the snippet is deleted while real leads continue.
How to check if your site has it
Check when the theme last updatedWordPress
In WordPress go to Appearance > Themes and note the version. Compare it with the date your conversions dropped.
View the page source
Open your site, press Ctrl+U (Cmd+Option+U on Mac) and search for your measurement ID, such as G-XXXXXXX, or for fbq( and gtag(.
Check the live tag in the browser
Open DevTools, go to the Network tab, reload, and filter for collect, gtm or facebook. No requests means the tag is not loading.
Compare the theme with a clean copy
Download the same theme version from its source and compare it with your files, or check your backups from before the update.
Test a conversion
Submit a test form or start a test checkout and watch Tag Assistant or GA4 DebugView for the event.
How to fix it
First restore the lost code from a backup or from your records. Then put it somewhere an update cannot overwrite. The best place depends on what the code does.
| Customisation | Safe home |
|---|---|
| Tracking snippets (GA4, Meta, Ads) | Google Tag Manager, or a header/footer plugin |
| PHP functions and hooks | A child theme functions.php or a small custom plugin |
| CSS tweaks | Appearance > Customize > Additional CSS, or child theme |
| Edited template files | Same file path inside a child theme |
Create a child theme
Make a folder in wp-content/themes named after your theme plus -child, with a style.css and functions.php (see the code below). Activate it under Appearance > Themes.
Move template edits
Copy any edited file, such as header.php, into the child theme at the same path. The child version is used instead of the parent's.
Move tracking into a plugin
Install a header and footer scripts plugin and paste the snippet there, or load it through a small custom plugin. Code in a plugin is untouched by theme updates.
Use Additional CSS for styles
Move CSS to Appearance > Customize > Additional CSS. Note this is stored per theme, so check it after a theme switch.
Add only the container snippet
Install the GTM container code once, ideally via a plugin rather than header.php.
Move tags into GTM
Create GA4, Google Ads and Meta tags inside the container and remove direct snippets from theme files to avoid double counting.
Publish and preview
Use Preview mode to confirm tags fire, then publish the container.
Package code as a plugin
Create a file in wp-content/plugins/site-tracking/ with a plugin header and hook into wp_head (see the code below).
Keep it in version control
Store the child theme or plugin in Git so changes can be restored and reviewed.
/*
Theme Name: My Theme Child
Template: my-theme
Version: 1.0.0
*/<?php
add_action( 'wp_enqueue_scripts', function () {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
} );<?php
/**
* Plugin Name: Site Tracking Snippets
*/
add_action( 'wp_head', function () {
?>
<!-- Paste your snippet here -->
<?php
}, 1 );Edits in the parent theme
- Snippet pasted into header.php
- Theme update replaces the file
- Tracking stops without any warning
Code outside the theme
- Snippet in Tag Manager or a plugin
- Template edits in a child theme
- Updates leave your code intact
How to confirm it's fixed
- View source shows your tag or GTM container exactly once
- Network tab shows hits to GA4 and each ad platform you use
- A test form submission or test checkout fires the conversion event in Tag Assistant or DebugView
- The child theme is active under Appearance > Themes
- Custom styles and template changes look the same as before
- Old snippets are removed from the parent theme
How to prevent it happening again
Before
Take a backup and note which tags and forms matter most.
Update on staging
Apply the theme update on a staging copy first and test forms and tracking.
Update live
Update production once staging passes.
Straight after
Re-run a test lead and check that tags fire.
Never edit a parent theme directly. Keep a short list of what you customised and where it lives, so anyone updating the site knows what to re-test. If you use a premium theme with auto-updates, consider turning them off for the theme and updating by hand after a staging test.
How FunnelGuard handles this
FunnelGuard detects this today. It notices when your theme changes and checks the tracking contracts, meaning the hits your journeys are supposed to send to GA4, Google Ads, Meta and the other platforms you use. If a theme change is followed by missing tracking, you get one alert with a screenshot and a likely cause.
A robot visitor runs your real journeys on a schedule, from the EU or the US. A failure is re-checked from a second region before alerting. Test traffic is marked with utm_source=funnelguard and fg_test=1. The Free plan covers 1 site and 2 journeys with daily checks and no card, and paid plans have a 3-day free trial.
Questions people ask
Why did my tracking stop after a WordPress theme update?
The update replaces the theme's files, so any snippet you pasted into header.php or footer.php is deleted. Check the page source for your measurement ID. If it is missing, restore the code and move it into Tag Manager, a plugin or a child theme.
Does updating a WordPress theme delete my customisations?
Yes, if you edited the parent theme's files directly. Those files are replaced on update. Settings saved in the database, such as Customizer options, usually survive, but edited PHP, template and CSS files do not.
How do I keep my changes when I update a WordPress theme?
Put edits in a child theme, a small custom plugin or Google Tag Manager instead of the parent theme. Parent theme updates then cannot touch them. Test on a staging copy before updating the live site.
Where should I put my Google Analytics code in WordPress so updates don't remove it?
Use Google Tag Manager or a header and footer scripts plugin, or load the snippet from a small plugin using the wp_head hook. Avoid pasting it into header.php of the parent theme.
Can I recover code lost in a theme update?
Yes, if you have a backup from before the update. Restore the old theme folder to a temporary location, copy your edits out, and place them in a child theme or plugin. Without a backup, you may need to rebuild the snippet from your analytics or ad account.
Do I need a child theme if I only add CSS?
Not always. CSS added in Appearance > Customize > Additional CSS is stored in the database and survives updates. It is tied to the active theme, so check it if you switch themes.
How can I tell quickly if a theme update broke my conversion tracking?
Run a test conversion after each update and watch for the event in Tag Assistant or GA4 DebugView. FunnelGuard can also do this on a schedule by running your journeys and checking the tracking hits.
Related issues
- OPS-234Plugin auto-update breaks contact formFix guide
- OPS-236Page builder (Elementor/Divi) update breaks layout or formsFix guide
- OPS-242WordPress core update breaking themeFix guide
- OPS-243Pending updates piling up (security debt)Fix guide
- OPS-239Caching plugin conflict (WP Rocket, LiteSpeed) breaking JSFix guide
- OPS-237Contact Form 7 / WPForms / Gravity Forms mail settings brokenFix guide