If you run a website on WordPress, there’s a good chance you have Google Analytics installed on it.
But with the forced migration from Universal Analytics to GA4, many site owners have ditched Google Analytics and moved on to other alternatives.
And if you find yourself in the same boat, you may be wondering how to remove Google Analytics from your WordPress site.
Well, you’re in luck.
In this article, we’ll cover everything you need to know to successfully remove Google Analytics from your WordPress site. From backing up your site to all of the removal methods available, we’ve got you covered.
Let’s dive in!
Preparing to Remove Google Analytics
Before you remove Google Analytics from your WordPress site, there’s a few key considerations to address beforehand.
First, you’ll want to go ahead and delete your Google Analytics account. While removing the tracking code from WordPress ensures no new data is ingested, deleting your account will ensure all existing data is permanently deleted as well.
Next, you’ll want to backup your site, which is crucial before making any big changes.
This is especially true when it comes to installing and uninstalling plugins. Doing so is the best way to safeguard your site from errors and downtime.
You can either backup your website manually or with the help of a plugin. If you’ve never done so before, I recommend reading this guide.
Identifying How Google Analytics Was Added
Once you’ve deleted your Google Analytics account and backed up your site, it’s time to remove the tracking code from WordPress.
But before you can do so, you’ll need to know how it was added in the first place.
If you know already, you can jump ahead to the next section.
But if not, here are a variety of methods you can use to determine how Google Analytics was installed on your site. Knowing this will be crucial for successfully removing it.
Option 1: Inspect the Site’s Source Code
A straightforward way to check if Google Analytics is installed and how it was added is by inspecting your website’s source code.
To do so, just follow these steps:
- Open your website in a browser and right-click on the page.
- Select “View Page Source.” Alternatively, you can press “Ctrl+U” on Windows or “Cmd+Option+U” on Mac.
- In the source code, press “Ctrl+F” on Windows or “Cmd+F” on Mac to open the search bar.
- Search for “Google Analytics” or the tracking ID (ie G-XXXXXXXX).
Assuming GA4 is installed directly, it should look like this:
<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>
If you find the tracking code in the <head> section, note how and where it appears.
- If it’s near the top, it’s likely been added manually using the WordPress theme editor or a child theme.
- If it appears within a specific section or commented by a plugin, it was likely added by a plugin or theme.
If you don’t find it at all, then it’s possible that Google Analytics was added via Google Tag Manager. If that’s the case, search for “GTM” or “Tag Manager” to locate the GTM container code.
It should look like this:
<!-- 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-XXXXXX');
</script>
<!-- End Google Tag Manager -->
Option 2: Check for Google Analytics Plugins
Another common method of adding Google Analytics to a WordPress site is through a plugin. To see if this is the case, follow these steps:
- Log in to your WordPress dashboard
- Navigate to Plugins > Installed Plugins
- Look for any plugins that are designed to add Google Analytics. Examples include MonsterInsights, Site Kit by Google, and GA Google Analytics.
If you find any of these plugins installed and activated, then they’re likely responsible for adding the Google Analytics tracking code to your site. To determine if this is the case, simply click on the plugin’s settings and verify the tracking ID.
Option 3: Review Theme Settings
Many WordPress themes also come with built-in options to add Google Analytics tracking without the need for a separate plugin. Here’s how to check if your theme is adding the code:
- Log in to your WordPress dashboard
- Navigate to Appearance > Customize or Appearance > Theme Options
- Look for a section related to analytics, tracking or scripts. This section might allow you to paste your Google Analytics tracking ID.
It’s also possible that your theme may have its own standalone settings page. For example, if you’re using Thesis, you would navigate to Thesis Home > Sitewide Options > Google Analytics.
But no matter what theme you’re using, the process should be fairly similar.
Removing Google Analytics
Now that you’ve identified how Google Analytics was added to your WordPress site, you can go ahead and remove it using the appropriate method.
Method 1: Manual Code Insertion
If Google Analytics was installed on your WordPress site manually, then you’ll need to remove the tracking script from your theme’s “header.php” or “footer.php” file.
To do so, log in to your WordPress dashboard and navigate to Appearance > Theme File Editor. From there, locate the “header.php” or “footer.php” file depending on where the script was added.
Then, within the appropriate file, search for the Google Analytics script. As a reminder, it should look like this:
<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>
Once you’ve found the code, delete the entire script block, save the changes, and clear any site caches to ensure the tracking code is fully removed from your site.
If you’re using a child theme, make sure to edit the corresponding files in the child theme to avoid losing changes during theme updates.
Method 2: Plugin
If Google Analytics was installed on your WordPress site via a plugin, then removing it is a straightforward process.
Start by logging in to your WordPress dashboard and navigating to Plugins > Installed Plugins. Then, look for the plugin that’s responsible for adding Google Analytics.
Once you’ve identified the plugin, you can either deactivate it or uninstall it entirely. Deactivating the plugin will stop it from running without removing it from your site, while uninstalling will completely remove all associated files and settings.
After deactivation or uninstallation, clear your site’s cache to ensure that no remnants of the tracking code remain.
Method 3: Google Tag Manager
If Google Analytics was installed on your WordPress site via Google Tag Manager (GTM), you’ll need to delete the associated tag from GTM.
To do so, log in to your GTM account and locate the container that is linked to your website. Inside the container, identify the tag associated with Google Analytics. Then, disable or delete this tag from the GTM workspace to stop them from firing.
After making these changes, publish the updated container to apply the changes to your live site.
Optional Step: Removing GTM
If you no longer need Google Tag Manager for any other tracking purposes, then it’s recommended that you also remove the GTM container itself from your WordPress site.
Similar to the steps above, this will either involve removing the GTM tracking code from your theme’s header/footer.php file or by disabling/deactivating a plugin. But in this case, you’re removing the GTM tracking script as opposed to the Google Analytics tracking script.
Method 4: WordPress Theme or Page Builder
If Google Analytics was added to your WordPress site via a theme or page builder, removing it typically involves accessing the specific settings within the theme or page builder where the tracking code was inserted.
Start by logging in to your WordPress dashboard and navigating to Appearance > Customize or Appearance > Theme Options if your theme has a dedicated settings panel. Look for sections related to analytics, tracking, or custom scripts, where the Google Analytics tracking ID or script might have been added.
Once you locate the tracking code or tracking ID, remove it and save your changes. Lastly, clear your site’s cache to ensure that the changes are reflected.
Wrapping Up
As you can see, there are a number of different ways that Google Analytics can be removed from your WordPress site.
So before you begin, it’s important that you identify how the tracking script was added in the first place, and to properly backup your site.
From there, it’s simply a matter of removing the Google Analytics tracking script using the appropriate method. Once removed, Google Analytics will no longer collect data and you can begin exploring alternatives.