How to Remove Google Analytics Tracking Code
Removing a Google Analytics tracking code from your website might feel like performing digital surgery, but it’s a lot simpler than it sounds. Whether you’re switching to a new analytics platform, cleaning up a faulty installation, or taking your site in a new direction, this guide will walk you through the process. We'll cover the most common scenarios so you can find the right steps for your specific setup.
Why Would You Need to Remove Your Google Analytics Code?
Before jumping into the "how," it’s helpful to understand the "why." You're not alone in needing to do this, and there are several perfectly good reasons to remove the tracking script:
- Upgrading to GA4: Many website owners have old Universal Analytics (UA) code lingering on their sites. Removing the outdated script is a key step in migrating fully to Google Analytics 4.
- Fixing a Double-Tracking Issue: Sometimes, a GA code is mistakenly added twice - once by a plugin and once manually, for example. This inflates your traffic data with duplicate pageviews, skewing your metrics. Removing one instance is necessary to get accurate reports.
- Switching Analytics Providers: You might be moving from Google Analytics to another platform like Plausible, Fathom, or Matomo and want to remove Google’s script entirely.
- Website Redesigns or Migrations: During a major site overhaul, it's often best practice to start with a clean slate to ensure your tracking setup is correct for the new structure.
- Decommissioning a Website: If you're shutting down a website, an old subdomain, or a temporary landing page, there’s no need to keep tracking its (non-existent) traffic.
First, Find Out How the Code Was Added
To remove the code, you first need to play detective and figure out how it was installed. The method of installation determines the method of removal. The good news is that you only need your web browser to solve this mystery.
Go to your website, right-click anywhere on the page, and select "View Page Source." This will open a new tab showing your site’s underlying HTML code.
Now, use your browser’s find function (Ctrl+F on Windows or Cmd+F on Mac) to search for the following text snippets:
`gtag.js`: This is the code snippet for the newer Global Site Tag, used by both Universal Analytics and GA4.`analytics.js`: This is the code snippet for the older version of Universal Analytics.`googletagmanager.com`: If you find this, it means Google Tag Manager (GTM) is installed. The GA code itself is likely managed inside your GTM account, not directly on your site.
Once you’ve identified which script is present, you know which of the following sections applies to your site. If you found the GA tracking snippet directly in the source code, it was likely added manually or through your theme settings. If you only see a Google Tag Manager script, you'll manage it there. And if you see neither, it was probably added using a plugin or a built-in platform integration.
How to Remove the Google Analytics Tracking Code
Pick the scenario below that matches how your code was installed. Remember to back up your site before editing any theme files, just in case something goes wrong.
Method 1: Removing Code Manually Added to HTML Files
If you discovered the `gtag.js` or `analytics.js` snippet directly in your page source, it was probably hardcoded into your website’s theme files. This is common for custom websites or older themes.
For a WordPress Site:
- Log into your WordPress dashboard and navigate to Appearance → Theme File Editor.
- On the right side, look for a file named Theme Header (header.php) and click on it.
- Scan the code within this file for the Google Analytics JavaScript snippet. It will start with
`<script>`and end with`</script>`. - Carefully select the entire script, from the opening
`<script>`tag to the closing`</script>`tag, and delete it. - Click "Update File" to save your changes.
- Finally, clear your website’s cache and your browser’s cache to see the changes.
If you don't use WordPress, the process is similar. You'll need to access your site’s files via an FTP client (like FileZilla) or your hosting provider’s built-in File Manager. The tracking code is most often located in an `index.html` file or a header template file.
Method 2: Uninstalling via a Plugin or App
Using a plugin is one of the most popular ways to add Google Analytics to CMS platforms like WordPress because it doesn’t require touching any code. Removing it is just as easy.
A. General WordPress Analytics Plugins (e.g., Site Kit, MonsterInsights):
If you’re using a dedicated analytics plugin, you usually have two options:
- Disconnect the Account within the Plugin: Navigate to the plugin’s settings in your WordPress dashboard. There will be an option to disconnect your Google Analytics account or simply remove the Tracking ID from its designated field. Save the settings, and the plugin will stop adding the code to your site. This is a good option if you plan to use the plugin again later.
- Deactivate and Delete the Plugin: If the plugin’s only job was to add Google Analytics, you can simply remove it completely. Go to Plugins → Installed Plugins, find the analytics plugin, click "Deactivate," and then click "Delete."
B. Theme or Page Builder Settings:
Some themes (like Divi or Avada) and page builders come with their own settings sections where you can paste tracking scripts. If this is your setup, you'll need to locate that specific settings panel.
- Go to your theme’s options panel, often found under "Appearance" or its own top-level menu item in the WordPress dashboard.
- Look for a tab or section labeled "Integrations," "Scripts," or "Analytics."
- Find the box containing your Google Analytics tracking code snippet and delete it.
- Save your changes and clear any caches.
Method 3: Platform-Specific Integrations (Shopify, HubSpot, etc.)
Popular hosted platforms like Shopify and HubSpot make adding GA even easier with native integrations. To remove the code, you'll use their built-in controls.
For Shopify:
- From your Shopify admin dashboard, go to Online Store → Preferences.
- Scroll down to the Google Analytics section.
- You'll see a box where your Google Analytics tracking code or snippet is pasted. Delete all the content in this box.
- Click "Save."
This disables Shopify's built-in integration. If the code was manually added to your Shopify theme's code, you'll need to follow the HTML editing steps (similar to Method 1) by going to Online Store → Themes → Actions → Edit code and checking the theme.liquid file.
For HubSpot:
- In your HubSpot account, click the Settings icon in the main navigation bar.
- In the left sidebar menu, navigate to Website → Pages.
- Click the Integrations tab at the top.
- Scroll down and uncheck the box that says "Integrate with Google Analytics."
- Save your changes.
Method 4: Removing a Tag in Google Tag Manager (GTM)
If you use Google Tag Manager, you’re in luck - this is the cleanest and safest way to manage tracking scripts. You don’t even need to touch your website. Instead, you'll make the change directly in your GTM account.
- Log in to Google Tag Manager and select the account and container for your website.
- In the left-hand navigation, click on "Tags."
- Find your Google Analytics tag in the list. It will typically be named something clear like "GA4 Configuration Tag" or "Universal Analytics Pageview Tag."
- You can either pause or delete the tag:
- Whether you pause or delete, you must publish your changes for them to go live. Click the blue "Submit" button in the top-right corner.
- Give your new version a name (e.g., "Removed GA Main Tag") and click "Publish."
GTM will push the changes to your site, and the GA tag will no longer be active. Note: If you are completely finished with tracking through GTM, you can also remove the GTM container script itself from your website’s HTML (following the steps in Method 1).
Last Step: Verify the Code Has Been Removed
Don't just assume it worked - always verify. Here are a few ways to confirm the Google Analytics tracking code is truly gone.
- Clear Your Caches: This is the most important step! Clear your website’s cache (if you use a caching plugin or service) and your browser's cache. If you skip this, you might still see a cached version of your site that includes the old code.
- Check the Page Source Again: Revisit your website in a private/incognito browsing window and view the page source again (right-click → "View Page Source"). Search for
`gtag.js`or your tracking ID (G-XXXXXXXXXX). If the search finds nothing, you’ve succeeded. - Use Google Tag Assistant: The legacy Tag Assistant Legacy Chrome extension is a simple tool for this. Install it, navigate to your site, enable it, and reload the page. If it doesn't detect any Google Analytics tags, you are good to go.
- Visit the GA Realtime Report: Log in to your Google Analytics property and open the Realtime report. Open your website on your phone or in another browser. If your visit doesn't appear in the Realtime report after a minute or two, the tracking code has been successfully scrubbed from your site.
Final Thoughts
Removing your Google Analytics tracking code is a straightforward task once you identify how it was first installed. Whether editing your theme's HTML, deactivating a plugin, or pausing a tag in Google Tag Manager, following the correct steps ensures a clean removal and sets you up for accurate analytics moving forward.
Once you get your analytics sorted, the challenge often shifts from collecting data to understanding it. We built Graphed because we believe getting insights shouldn’t require hours of building reports. After connecting sources like Google Analytics, Shopify, and your ad platforms in a few clicks, you can use plain English to build real-time dashboards and reports. Instead of grappling with dozens of tabs and CSV files, you just ask what you want to know and get an instant visual answer, helping you make smarter decisions, faster.
Related Articles
How to Enable Data Analysis in Excel
Enable Excel's hidden data analysis tools with our step-by-step guide. Uncover trends, make forecasts, and turn raw numbers into actionable insights today!
What SEO Tools Work with Google Analytics?
Discover which SEO tools integrate seamlessly with Google Analytics to provide a comprehensive view of your site's performance. Optimize your SEO strategy now!
Looker Studio vs Metabase: Which BI Tool Actually Fits Your Team?
Looker Studio and Metabase both help you turn raw data into dashboards, but they take completely different approaches. This guide breaks down where each tool fits, what they are good at, and which one matches your actual workflow.