How do I fully remove an old analytics tag and its cookies from my site?

Find every place the old tag loads, including page templates, any tag manager container and any plugin or site-builder setting, and remove each one. Then load several pages in a private window with developer tools open and confirm that no request reaches the old tool. Expire its leftover cookies by setting them again with a past date.

Last updated 26 November 2026. By Paul Badarau.

Say you took over a client's site. The old analytics tag is in the theme header, again inside a tag manager container, and a third time in the site builder's integration settings. Deleting the header copy leaves two that still load, and the old tool keeps setting cookies.

  1. Search your code. Look for the old script's address and the site ID it uses, in the repository and in the built HTML. A copy can hide in a single page template or a static page.
  2. Check the places outside your code. A tag manager container can load the old tag alongside others, and a CMS plugin, a site-builder setting or a consent tool can inject it as well. Remove the tag from each one. If analytics was the tag manager's only job, remove the tag manager too.
  3. Deploy, then check in a browser. Open a private window and the Network tab of the developer tools, filter for the old tool's domain, and load several kinds of page, such as the home page, an article and a form. No request should reach the old tool.
  4. Expire the cookies it left. The Application or Storage tab lists the cookies on your domain. A browser deletes a cookie when your site sets it again with the same name, domain and path and a date in the past, so a short script or a Set-Cookie header can clear them for returning visitors. Remove that code once the old cookies would have expired anyway.
  5. Update the text around the tag. Take the old tool out of your privacy policy and out of your consent tool's list.

A cached copy of a page can keep serving the old tag after you deploy. Your host's cache, a visitor's browser cache and a service worker can all hold one, so purge what you control and check again a day later. A cookie already stored in a visitor's browser also stays there until it expires or your site overwrites it. Removing the script does not delete it.

If PostDeploy Analytics replaces the old tag, add the Project's snippet and wait for the first valid event, because only a received event confirms installation. The Analytics script sets no cookies, so any cookie you still find after the cleanup comes from something else on the page. Whether the site still needs a consent banner depends on everything else it stores and where you operate, and that is a legal question.

The product page for this is Analytics.

Start your 14-day free trial