Removing the tag from one file rarely removes it from the site. Inventory every loader, export your history, take it out in order, and verify.
The hard part is finding every place the tag lives. A typical site loads Google Analytics from more than one spot: a hard-coded snippet, a tag manager container, a CMS plugin, a theme option, a consent tool that fires it. Remove only one and the tracker keeps running from another, with the consent banner still on screen.
_ga cookies.The numbered how-to below takes most sites under an hour. Sites with a tag manager and several plugins should plan for two.
Before you touch anything, list where Google Analytics is loaded. The tracker is the same library whichever way it arrives, so the goal is to find every loader. Open your site in a private window, open DevTools, switch to the Network tab and filter for googletagmanager, google-analytics and collect. Whatever shows up is your evidence; the table below tells you where to look for the source.
| Where it hides | What it looks like | How to find it |
|---|---|---|
| Hard-coded snippet | A gtag.js script in the page head plus a gtag('config', 'G-…') call | View source and search for gtag; search the theme or layout files |
| Tag manager container | A GTM-… snippet in the head and a noscript iframe after the body tag | Search for googletagmanager.com/gtm.js; then open the container and look at its tags and triggers |
| CMS plugin | A Google Analytics, Site Kit or analytics-dashboard plugin with a measurement ID saved in settings | The plugin list in your CMS admin; search plugin settings for G- |
| Theme or builder option | A "tracking code" or "Google Analytics ID" field in theme settings or a site-builder panel | Theme customizer, site-builder integrations screen |
| Consent tool | A banner that loads the tag after a visitor accepts | The consent platform's script list or category settings |
| Server-side tagging | Requests to your own subdomain that forward to Google | Network tab requests to a first-party tagging host; your tag manager's server container |
| Other products | Ads conversions, remarketing audiences or reports that read from the same property | The property's linked-products settings in Google's admin |
Write the list down with the owner of each item. On a site with an agency or several developers, the container and the plugin are often managed by different people.
Removing the tag does not delete your history, but it stops adding to it, and the property's data is subject to Google's retention settings. Decide now what you want to keep and export it while the property is still receiving data. Our guide to exporting your GA4 history covers the options in detail; the short version is below.
Nothing from GA4 carries over into GhostMetrics automatically; the new tool starts counting from the day you install it. That is why running both for a couple of weeks, as described in our migration guide, is worth it if you need a continuous baseline.
The blocks to search for in templates look like this:
<!-- Google tag (gtag.js) -->
<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>
On a WordPress site that adds the tag from a theme function, the hook to delete or comment out is the one that prints into wp_head:
// functions.php - remove or comment out the hook that prints the tag
// add_action('wp_head', 'my_theme_print_gtag');
Static sites built with Hugo, Jekyll or Astro usually keep the snippet in a head partial or base layout; search the repository for gtag and googletagmanager, remove the matches, rebuild and redeploy.
Cookie-based analytics generally requires consent in the EU and UK, which is why most Google Analytics installs come with a banner. Once Google Analytics is gone and nothing else on the page sets non-essential cookies, the reason for the banner may go with it. That depends on everything else the site loads, so audit before you delete.
GhostMetrics sets no cookies and does not use localStorage; its only browser storage is a per-tab counter and the session's first-touch UTM values in sessionStorage. If analytics was the sole reason for your banner, you may be able to drop it after the swap. If it was not, the banner stays.
Removing the tag from your site stops new data from arriving. It does not delete the property, your reports or your linked products. The property stays in your Google account until you delete it yourself, and data it already holds follows Google's retention settings. Check the current Google Analytics documentation for how property deletion works and whether a deleted property can be restored, because Google changes the details and this page does not quote timelines.
A sensible sequence is: remove the tag, wait until your exports are verified against the originals, unlink anything that still points at the property, and only then decide whether to delete it. Keeping an idle property costs nothing and keeps your reports readable. If the property has Google Ads linked, move any conversion imports to a different source before removal, or those imports stop.
Most failed removals come from the same handful of oversights. Each one is easy to check once you know it exists.
gtag('config', …) while leaving the gtag.js script means the library still downloads on every page, which wastes bytes and still shows up in the Network tab. Remove the whole block.G- and UA- pattern, not just the one you know.Run the DevTools checks on at least one page of each type: the home page, a blog post, a checkout or contact page and any page built on a different template. A single template that still loads the tag is enough to keep collecting data, and it often hides on the pages you visit least.
With Google Analytics gone, add the replacement. GhostMetrics is one tag in the head, on any host, with no plugin and no build step:
<script defer src="https://ghostmetrics.nullagency.io/gm.js" data-site="YOUR-SITE-ID"></script>
Create the site in the dashboard to get your site ID. Static-site and framework placement is covered in our guide to adding analytics to a static site, and WordPress owners can follow analytics on WordPress without Google. Then confirm the whole change worked:
| Check in DevTools | Expected after removal |
|---|---|
Network tab, filter googletagmanager | No requests, unless you kept a tag manager container for other tags |
Network tab, filter collect | No requests to Google's analytics endpoints; one request to the GhostMetrics endpoint on each page view |
| Application, Cookies | No _ga or _ga_ cookies on a fresh private window |
| Console | No errors from leftover gtag(...) calls; if you see "gtag is not defined", a template still calls it |
| View source | No gtag, G- measurement IDs or GTM- snippets in the head or body |
| GhostMetrics dashboard | Your own visit appears under Live within a few minutes |
If your own visit does not show up, check that Global Privacy Control or Do Not Track is not enabled in your browser, since the tracker honors both and collects nothing. Our guide to testing your analytics install walks through the other common causes. After a day of traffic, compare orders of magnitude with the baseline you recorded in step one; the totals will not match exactly, because tools differ on bot filtering, blockers and consent. If you are still choosing a replacement, our GA4 alternatives comparison lays out the options.
GhostMetrics is cookieless web analytics by Null Agency, and we use it on this site. No cookies, no localStorage, no stored IP addresses. The free plan is free forever: one site, unlimited pageviews, a real-time dashboard, every view and full history. Raw event export as CSV or JSON is available on every plan, including free.
Managing several sites, or want a public shareable dashboard? Pro is $9.99/mo flat with unlimited pageviews and unlimited websites (fair-use ceiling of 250), with a 30-day free trial. A card starts the trial, nothing is charged for 30 days, and you can cancel anytime. It does not replace Google Ads attribution, audiences or ecommerce funnels, so keep Google's tools if those are essential to you.
Start free — no card See the live demoDisclosure: GhostMetrics is built by Null Agency and we use it on this site, so we are not a neutral party about our own product. Google's products and terms change; check Google's current documentation before deleting any property or relying on a retention period.