Articles on: Getting Started & Setup

Uninstalling Google Tag Manager from Wordpress

In order to install Bot Badger on your website, you must make sure that Google Tag Manager is not installed directly into your website.

Google Tag Manager can be integrated into a WordPress site in several ways.

First, we will go through each of the most common methods of installation and provide instructions on how to remove or uninstall Google Tag manager from each.

Then, we'll share how to verify that you have removed Google Tag Manager successfully.

Step 1: Removing Google Tag Manager


There are multiple ways Google Tag Manager can be installed on a Wordpress site. If you know how yours is installed, jump to that option. If not, start at the top and work your way down until you hit the installation type used on your site.

1. Via a Plugin

Plugins like "GTM4WP," “MonsterInsights,” "Google Site Kit," or “WP Google Tag Manager” are widely used for integrating Google Tag Manager with Wordpress.

If you Navigate to ‘Plugins’ on the left sidebar and scan the list and see one of these plugins (or any other plugin saying it loads Google Tag Manager), here's how to remove it:
Login to your WordPress dashboard.
Navigate to ‘Plugins’ on the left sidebar.
Find the Google Tag Manager plugin you are using.
Click ‘Deactivate.’
After the plugin is deactivated, you can click ‘Delete’ to remove it from your site completely.

2. Using a Theme’s Built-In Option

Some themes have a built-in field for Google Tag Manager code. This one's a little trickier to figure out, because each theme's configuration is different.

Here's how you can search your theme's configuration to hunt for a Google Tag Manager setting, and deactivate it if found:
Login to your WordPress dashboard.
Go to ‘Appearance’ > ‘Customize.’
Navigate to the theme settings/options. The exact location can vary based on the theme; it might be under ‘Theme Options,’ ‘Header,’ or ‘Footer’ settings.
Find the field where the Google Tag Manager code is pasted. It is typically a text area where you can paste scripts to be included in your site’s header or footer. For some sites, it's just a field where you paste your GTM container ID (look for a string of numbers, preceded by "G-" like G-9845738749).
Delete the Google Tag Manager tracking code or Container ID.
Click ‘Publish’ to save your changes.


Google Tag Manager can also be added by a developer by copying and pasting the tracking code directly into the header.php or footer.php file. The good news is that if you're careful, you don't need a developer to remove it.

> IMPORTANT NOTE: Directly editing theme files can be risky; always back up your site before making changes.

To search your theme's header.php and footer.php files for Google Tag Manager and remove it if found:
Login to your WordPress dashboard.
Navigate to ‘Appearance’ > ‘Theme Editor.’
Locate the header.php or footer.php from the list of theme files on the right-hand side.
Look for the Google Tag Manager script tag. It will look something 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 -->

Also keep an eye out for the Google Tag Manager noscript tag. It will look something like this:
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-53JRC7Q"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->

Carefully delete the script tags related to Google Tag Manager.
Click ‘Update File’ to save your changes.

4. Via Functions.php File

Developers sometimes add the Google Tag Manager code to the functions.php file of a theme. Unfortunately, if you are not comfortable with code, specifically PHP, you are probably best off working with your web developer to remove it.

> IMPORTANT NOTE: Directly editing theme files can be risky; always back up your site before making changes.

To remove Google Tag Manager from the functions.php file:
Login to your WordPress dashboard.
Navigate to ‘Appearance’ > ‘Theme Editor.’
Select the functions.php file from the list of theme files.
Search for the function that enqueues the Google Tag Manager script. It might be hooked to wp_head or wp_footer.
Remove the function and/or the action hook that adds the Google Tag Manager code.
Click ‘Update File’ to save the changes.

Step 2: Clear Your Cache


Most, but not all, Wordpress websites have a caching plugin installed to prevent the site from having to run all the code every time a page loads. Instead, it saves the results of running the code in something called a cache, and serves that when visitors hit the site.

Because of this, taking the steps above may not remove Google Tag Manager from your site.

There are several different caching plugins out there, but they all work roughly the same way. Let's cover the process for clearing the cache in three of the most popular ones. Your process will be very similar.

If You Have WP Rocket

Login to your WordPress dashboard.
Go to the top admin bar while logged into your dashboard. Hover over the “WP Rocket” menu.
Click on “Clear Cache.” This option will clear the entire cache created by WP Rocket.
WP Rocket should show a confirmation message at the top of the page indicating that the cache has been cleared.

If You Have W3 Total Cache

Login to your WordPress dashboard.
On the left sidebar, hover over the “Performance” menu and click on “Dashboard”
Inside the W3 Total Cache Dashboard, click on “empty all caches.”
A confirmation message will typically appear to let you know the caches have been successfully emptied.

If You Have WP Super Cache

Login to your WordPress dashboard.
On the left sidebar, click on “Settings” and then choose “WP Super Cache.”
In the WP Super Cache settings, go to the “Easy” tab.
Click on the “Delete Cache” button found in the “Delete Cached Pages” section.
WP Super Cache will display a message at the top of the page confirming that the cache has been deleted.

If You Have Another Caching Plugin

If you see references to "cache" in the menu, and the above three processes don't seem applicable to you:
Login to your WordPress dashboard.
Navigate to ‘Plugins’ on the left sidebar.
Look for any plugin with cache in the name or description.
Refer to their documentation or your favorite search engine to find out how to clear your cache.

Updated on: 04/12/2023

Was this article helpful?

Share your feedback

Cancel

Thank you!