Why Google Analytics Tracking Code Remains After Uninstalling MonsterInsights (And How to Fix It)
Content
You've followed the standard procedure: deactivated the MonsterInsights plugin and then deleted it. But when you check your website's source code, the Google Analytics tracking snippet is still there. This is a common and confusing issue reported by many users. This guide explains why it happens and provides the most effective solutions to completely remove the tracking code.
Why Does the Tracking Code Stay After Uninstallation?
Contrary to what one might expect, the tracking code lingering after a plugin is deleted is almost never because the plugin itself left permanent code changes. WordPress plugins are designed to stop outputting code the moment they are deactivated. Based on numerous community reports, the culprit is typically one of the following:
- Website Caching: This is the most common reason. Caching plugins or server-level caching systems store static HTML copies of your pages to serve visitors quickly. When you delete a plugin, these stored copies still contain the old code until the cache is completely cleared.
- A Different Source: The code you're seeing might not be from MonsterInsights at all. It could have been added manually to your theme's
header.phporfunctions.phpfile, or entered into a theme or other plugin's settings panel long before MonsterInsights was installed.
How to Completely Remove the Tracking Code
Follow these steps to locate and remove the persistent tracking code.
Step 1: Clear All Caches
Before doing anything more complex, always clear your website's cache. This is the most likely solution.
- Clear Plugin Caches: If you use a caching plugin like WP Rocket, W3 Total Cache, or WP Fastest Cache, find its settings in your WordPress dashboard and use the "Clear All Cache" or "Purge Cache" function.
- Clear Server-Level Cache: If your hosting provider offers caching (e.g., Cloudflare, Varnish, or proprietary host caching), check your hosting control panel (e.g., cPanel) for cache management options or contact your host's support to ensure it's purged.
- Clear Browser Cache: Finally, clear your own browser's cache or perform a "hard reload" (Ctrl+F5 on Windows, Cmd+Shift+R on Mac) to view the updated, uncached version of your site.
Step 2: Verify the Code is Truly Gone
After clearing all caches, open your website in a browser, view the page source (Right-click > View Page Source), and search for text like "monsterinsights", "google-analytics", or your "UA-" tracking ID. If the code is gone, the process is complete.
Step 3: Investigate Other Sources (If the Code Remains)
If the tracking code persists after a full cache purge, it was likely not inserted by MonsterInsights. You will need to search for its origin.
- Check Your Theme's Settings: Many modern themes have a dedicated "Google Analytics" field in their customizer or theme options panel. Navigate to Appearance > Customize or look for a "Theme Options" menu and remove any tracking ID entered there.
- Search Theme Files: The code may have been hardcoded. Go to Appearance > Theme Editor. Carefully check the
header.php,footer.php, andfunctions.phpfiles for the analytics code. Warning: Editing theme files directly can break your site; create a backup first. - Check Other Plugins: Another SEO, analytics, or marketing plugin could be adding the code. Temporarily deactivate other plugins one by one, checking your site's source code after each deactivation to see if the tracking code disappears.
Important Note on Google Analytics Property Access
Uninstalling the plugin from WordPress only removes the code from your website. It does not automatically revoke the plugin's access to your Google Analytics property. To fully remove access, you must log into your Google Analytics account, navigate to Admin > Property Access Management, and remove the permission granted to "MonsterInsights" or similar.
Conclusion
A persistent tracking code after uninstalling a plugin is almost always a caching issue. The solution is a thorough cache clearance at every level. If the problem continues, the investigation should shift to other common places where analytics code is stored, such as theme options or files. By methodically following these steps, you can ensure your site is completely free of the old tracking code.
Related Support Threads Support
-
Removing the plugin affects google analytics toohttps://wordpress.org/support/topic/removing-the-plugin-affects-google-analytics-too/
-
Unsubscribehttps://wordpress.org/support/topic/unsubscribe-65/
-
Where is google analytics code in database ?https://wordpress.org/support/topic/where-is-google-analytics-code-in-database/
-
Tracker code remains after deleting the pluginhttps://wordpress.org/support/topic/tracker-code-remains-after-deleting-the-plugin/
-
uninstall and remove the pluginhttps://wordpress.org/support/topic/uninstall-and-remove-the-plugin/
-
Gtag loads in after disablinghttps://wordpress.org/support/topic/gtag-loads-in-after-disabling/
-
Remove Google analytics tracking codehttps://wordpress.org/support/topic/remove-google-analytics-tracking-code/
-
UA pageview code showing on left top corner of sitehttps://wordpress.org/support/topic/ua-pageview-code-showing-on-left-top-corner-of-site/
-
Do I need to add Google Analytics code?https://wordpress.org/support/topic/do-i-need-to-add-google-analytics-code/
-
Exclude pages from Analytics?https://wordpress.org/support/topic/exclude-pages-from-analytics/
-
Became installed without my permissionhttps://wordpress.org/support/topic/became-installed-without-my-permission/
-
Google Analytics Code Showing in Mobile Bannerhttps://wordpress.org/support/topic/google-analytics-code-showing-in-mobile-banner/
-
2 plugins loadedhttps://wordpress.org/support/topic/2-plugins-loaded/
-
Remove google tags from page codehttps://wordpress.org/support/topic/remove-google-tags-from-page-code/
-
How to delete codes installed by your plugin?https://wordpress.org/support/topic/how-to-delete-codes-installed-by-your-plugin/
-
Cannot Remove Tracking Codehttps://wordpress.org/support/topic/cannot-remove-tracking-code/
-
UA Code Problemshttps://wordpress.org/support/topic/ua-code-problems/
-
Duplicate Analytics Codehttps://wordpress.org/support/topic/duplicate-analytics-code/
-
Google Analytics tracking codehttps://wordpress.org/support/topic/google-analytics-tracking-code-4/
-
UA Code on websitehttps://wordpress.org/support/topic/ua-code-on-website/
-
Moving to Clicky by Yoasthttps://wordpress.org/support/topic/moving-to-clicky-by-yoast/
-
GA Code Not Addedhttps://wordpress.org/support/topic/ga-code-not-added/
-
Where does the plugin put the Google Analytics code?https://wordpress.org/support/topic/where-does-the-plugin-put-the-google-analytics-code/
-
Two Google Analytics Tagshttps://wordpress.org/support/topic/two-google-analytics-tags/
-
Displays code on websitehttps://wordpress.org/support/topic/displays-code-on-website/
-
How to Remove Tag from Source Code?https://wordpress.org/support/topic/how-to-remove-tag-from-source-code/
-
GA code is implemented Multiple timeshttps://wordpress.org/support/topic/ga-code-is-implemented-multiple-times/
-
plugin deactivationhttps://wordpress.org/support/topic/plugin-deactivation-3/
-
Conflict with Google Tag Managerhttps://wordpress.org/support/topic/conflict-with-google-tag-manager-2/
-
What about the code if I remove the plugin?https://wordpress.org/support/topic/what-about-the-code-if-i-remove-the-plugin/
-
Can't get rid of coubleclick cookihttps://wordpress.org/support/topic/cant-get-rid-of-coubleclick-cooki/
-
I now have 2 sets of GA codehttps://wordpress.org/support/topic/i-now-have-2-sets-of-ga-code/