Skip to content
FunnelGuard

Fix guide by FunnelsGuard

GA4 tag missing site-wide after a theme change: how to fix it

TRK-002High impactDetectedBy FunnelGuardPublished Updated
On this page

What this issue is

GA4 is Google Analytics 4, the current version of Google's analytics. It collects data when a small piece of code, the GA4 tag (also called the Google tag or gtag.js), loads on your pages. If the tag is not there, GA4 records nothing.

This issue is the site-wide version of that problem. The tag was working, then you changed the theme, updated it, switched page builder or migrated to a new platform. The code lived in the old theme's header.php, a custom code box or a template, so it disappeared from every page at once.

Why it costs you leads or sales

With no tag, GA4 shows no sessions, no key events and no revenue. You cannot tell which channels bring leads. Google Ads and other tools that import GA4 conversions or audiences also lose their data, so bidding and reporting can drift without anyone noticing.

The damage is also permanent. GA4 cannot backfill days when nothing was collected. Every day the tag stays missing is a gap in your history.

Where the data stops
  1. Theme or builder changeOld header code is no longer used
  2. GA4 tag on pagesSnippet gone from every page
  3. GA4 hitsNo page_view or key events sent
  4. Reports and ad importsFlat lines, missing conversions

The theme change breaks the tag, so everything after it is lost.

Daily sessions recorded in GA4Example numbers
Daily sessions recorded in GA4 (example)Mon: 420 sessions; Tue: 410 sessions; Wed (theme switched): 15 sessions; Thu: 0 sessions; Fri: 0 sessions01613224204101500MonTueWed (theme switched)ThuFrisessions

Example: a site with steady traffic drops to near zero in GA4 the day after a theme switch, although real visitors keep arriving.

How to check if your site has it

Confirm the tag is missing
  1. Check GA4 Realtime

    Open your site in a private window, then look at Reports > Realtime in GA4. If you do not appear within a minute or so, continue. Ad blockers and consent banners can hide you, so test with them off.

  2. View the page source

    On your home page, right-click, choose View page source and search for googletagmanager.com and G-. Do this on a few different pages.

  3. Check the Network tab

    Open browser DevTools > Network, reload, and filter by collect or gtag. A working install shows a request to google-analytics.com/g/collect.

  4. Use Tag Assistant

    Open tagassistant.google.com, enter your URL and see whether a Google tag or GTM container is detected.

  5. Compare with your GA4 data

    In GA4, look at Reports > Engagement > Pages and screens by day. A sudden cliff on the date of the change points to this issue.

How to fix it

First find your measurement ID. In GA4 go to Admin > Data streams, open your web stream and copy the ID that starts with G-. Then reinstall the tag in a place that is not tied to the theme.

Reinstall the GA4 tag
  1. Use a plugin, not theme files

    Install a tag plugin such as Site Kit by Google, or a header and footer scripts plugin, and add your G-ID there. Plugins survive theme switches.

  2. Check for duplicates

    If a plugin or the new theme already adds GA4, do not add it twice. Pick one method.

  3. Clear caches

    Purge your caching plugin and CDN so the updated header is served.

Google tag (replace G-XXXXXXXXXX with your ID)html
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'G-XXXXXXXXXX');
</script>

How to confirm it's fixed

After reinstalling
  • Open a private window, visit several pages and see yourself in GA4 Realtime.
  • View source on the home page, a landing page and a thank-you page and find your G- ID.
  • In DevTools > Network, see a g/collect request on each page load.
  • Tag Assistant detects the Google tag with the right measurement ID.
  • Submit a test form and check that your key event appears in Realtime.
  • Check again the next day that sessions are back in standard reports.

How to prevent it happening again

The root cause is storing tracking code inside something you replace. Keep it somewhere that outlives the design.

Prevention habits
  • Install GA4 through a plugin, GTM or the platform's global setting, not in theme files.
  • Add 'verify analytics' to your launch checklist for any theme, builder or migration change.
  • Test a staging copy before switching the live theme.
  • Set a GA4 custom insight or routine check for sudden traffic drops.
  • Keep a note of the measurement ID and where the tag lives.

How FunnelGuard handles this

FunnelGuard detects this issue today. A robot visitor runs your real customer journeys on a schedule and checks the tracking hits sent to GA4 at each step. If the GA4 hits stop appearing across your journeys after a theme or builder change, the failure is re-checked from a second region, then you get one alert by email, Slack, Teams, WhatsApp, webhook or PagerDuty, with a screenshot and a likely cause.

The Free plan covers 1 site and 2 journeys with daily checks and no card. Paid plans start at $39/month with a 3-day free trial. A free read-only website audit is also available.

Questions people ask

Why did GA4 stop tracking after I changed my theme?

The GA4 snippet was most likely stored in the old theme's header file or settings. A new theme does not carry that code over, so no page loads the tag and GA4 receives nothing. Reinstall it through a plugin, Google Tag Manager or the platform's global setting.

How do I check if my GA4 tag is still on my website?

View the page source and search for googletagmanager.com and your G- measurement ID, or open DevTools > Network and look for a g/collect request. You can also run your URL through Google Tag Assistant and check GA4 Realtime.

Will I lose GA4 data while the tag was missing?

Yes. GA4 only records visits while the tag is loading, and it cannot backfill the gap. Fix it quickly to limit the missing days, and note the gap in your reports.

Where should I put the GA4 tag so a theme change does not remove it?

Use something independent of the theme: a plugin such as Site Kit on WordPress, Google Tag Manager, the Shopify Google and YouTube channel, or the global code injection or integration settings in Webflow, Wix and Squarespace.

Why does GA4 Realtime show no users even though the tag is installed?

Common causes are an ad blocker, a consent banner blocking analytics, a wrong measurement ID, or a cached page without the new code. Test in a private window with blockers off, and purge your cache.

How do I find my GA4 measurement ID?

In GA4, go to Admin > Data streams, open your web stream and copy the ID at the top right. It starts with G-.

Can I get alerted if GA4 disappears from my site again?

Yes. FunnelGuard runs your journeys on a schedule and checks that GA4 hits are sent. If they stop, it re-checks from a second region and sends one alert with a screenshot and a likely cause.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

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.