/ โ† JavaScript Checker Fixes / Third-Party Tags
In this guide
  1. Why tags pile up
  2. Building the tag inventory
  3. Choosing when each tag loads
  4. Consent and the tag manager
  5. The fix, step by step
  6. Controlling what can be added
  7. Server-side tagging and other loading options
  8. Questions and answers

Why tags pile up

Tag bloat is an organisational problem before it is a technical one. A tag manager makes it easy for marketing, sales and agencies to add code without a developer, which is its purpose. The same ease means there is rarely a matching step for taking code away. Campaigns end, tools are replaced and agencies change, but their tags keep firing.

The costs land in several places at once:

๐Ÿ’ก This guide focuses on governing and loading tags. For the general mechanics of defer and async on hard-coded scripts, see fixing render-blocking scripts.

Building the tag inventory

You need one list of every tag, wherever it lives. Collect from three places:

  1. What the browser actually loads. The JavaScript Checker lists the third-party tags on a page with their cost. Run it on your main templates and on the confirmation page after a test purchase or form submission, where conversion tags usually fire.
  2. What the tag manager contains. Export the container or go through the Tags list, including paused tags.
  3. What is hard-coded. Search the site templates, CMS header and footer settings, plugin or app settings and any "custom code" boxes for script tags.

Record each tag in a shared sheet with these columns:

ColumnExampleWhy it matters
Tag and vendorHeatmap tool, session recordingWhat it is, in words a non-developer understands.
Where it livesGTM tag 14, or theme headerSo you can switch it off quickly.
Business ownerNamed person in marketingWho decides whether it stays.
Purpose and report it feedsUX review each monthIf nobody uses the output, the tag has no purpose.
Pages and triggerProduct pages, Window LoadedWhether it loads more widely than needed.
Consent categoryAnalyticsWhich consent choice must be granted first.
CostScript size and main-thread time from the checkerWeigh against its value.
Review or end date31 MarchCampaign tags should expire.

Any tag without an owner after a reasonable chase is a candidate for removal. Pause it first rather than deleting, so it can be restored if someone turns out to need it.

Choosing when each tag loads

In a tag manager, the trigger decides not just which pages a tag runs on but when during the page load it runs. Moving a tag to a later trigger is often the easiest speed gain available, and it costs nothing in data for tags that do not need the earliest moment.

Google Tag Manager triggerWhen it firesSuits
Consent InitializationBefore anything elseConsent management platform and default consent settings only.
InitializationBefore page view triggersSettings that other tags depend on.
Page ViewAs soon as the container loadsMain analytics page view.
DOM ReadyAfter the HTML has been parsedTags that read page elements.
Window LoadedAfter images and other resources finishHeatmaps, secondary pixels, most marketing tags.
Element Visibility, Scroll Depth, Click, TimerOn a visitor action or after a delayChat widgets, surveys, engagement tracking.
Custom EventWhen your code pushes an event to the data layerConversions such as purchase or form submission.

Narrow the pages as well as the timing. A booking widget tag needs a trigger condition limited to booking pages; a conversion pixel needs the confirmation event, not All Pages. Set tag firing options to once per page where repeat firing makes no sense.

For heavy visible widgets such as live chat, consider a facade: a lightweight button styled like the widget, with the real script loading only when the visitor clicks it. Many chat vendors document a way to open the widget from your own button.

The fix, step by step

Step 1

Build a tag inventory with owners

Run the JavaScript Checker on your key templates and on a confirmation page to list the third-party tags that actually load. Add every tag from the tag manager, including paused ones, and every script hard-coded in templates, CMS settings and plugins. Put them in a shared sheet with the vendor, location, business owner, purpose, trigger, consent category, cost and a review date, and chase an owner for each unclaimed tag.

Step 2

Measure what each tag costs

Take the size and execution time of each tag from the checker. To see the real effect on the page, open DevTools, right-click a tag's request in the Network panel and block its domain, then reload and compare a Performance recording with and without it. Note tags that load many further scripts or run long tasks. Record the cost in the inventory so owners can weigh it against the value.

Step 3

Remove dead, duplicate and hard-coded tags

Pause tags with no owner, tags for tools the business has stopped paying for, and tags for finished campaigns. Where the same vendor appears twice, for example a pixel in both the theme and the container, keep one copy and remove the other. Move remaining hard-coded tags into the tag manager so all of them are governed in one place. Delete paused tags once nobody has asked for them after an agreed period.

Step 4

Give every remaining tag the right trigger

Change All Pages triggers to the specific pages each tag needs, and move tags that do not need the first moment of the load to DOM Ready or Window Loaded. Fire conversion tags on a data layer event from your own code rather than on a thank-you page view. Load chat and survey widgets on a click, timer or scroll trigger, and set firing to once per page where repeats would double-count.

Step 5

Wire consent into the container

Load your consent platform on the Consent Initialization trigger and set default consent states to denied for non-essential categories. Enable consent mode for Google tags, and give every non-Google tag an additional consent check for its category. In preview mode, decline everything and confirm only essential tags fire, then accept each category in turn and confirm the matching tags start. Take advice on your obligations; this is not legal advice.

Step 6

Restrict who can publish and what can run

Review user access in the tag manager. Give most people edit or read rights and keep publish rights to a small, named group who check changes before they go live. Limit or block Custom HTML tags where possible, using built-in templates instead, because custom code can do anything on any page. If you use a Content Security Policy, list only the tag domains you have approved so unapproved scripts are refused.

Step 7

Publish as a named version and review quarterly

Test the container in preview mode on each template, then publish with a version name and a description that lists what changed, so it can be rolled back quickly. Re-run the JavaScript Checker to confirm fewer tags and less main-thread time. Put a quarterly review in the calendar where each owner confirms their tags are still needed, and remove any that pass their review date unclaimed.

Controlling what can be added

Governance only lasts if adding a tag goes through a process. A light version that suits most small teams:

<!-- Before the container snippet: stop Custom HTML tags running on this site -->
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({ 'gtm.blocklist': ['customScripts'] });

Test a blocklist in preview mode before publishing, because any existing tag of that type will stop firing.

Server-side tagging and other loading options

None of these replaces removing tags that nobody needs. The cheapest tag is the one that is not there.

Questions and answers

1. How many third-party tags is too many?

There is no official number. The right question is whether each tag has an owner, a purpose that someone acts on, and a cost that is worth it. A site with five tags that all fire on every page before consent may be in worse shape than one with fifteen that load late, on the right pages and only after consent. Use the inventory to judge each tag on its own merits, and remove anything nobody can justify.

2. Does using Google Tag Manager make my site slower?

The container itself adds a script, but the bigger effect comes from the tags inside it. A tag manager can make things faster if you use it to control when and where tags load, move non-essential tags to later triggers, and remove duplicates. It makes things slower when it becomes a place where anyone can add scripts to every page with no review. Governance, not the tool, decides which of those you get.

3. Should I move hard-coded tracking scripts into the tag manager?

Usually yes. Having every tag in one place makes it possible to see them all, apply consent rules consistently, change triggers without a developer and roll back mistakes. The exceptions are scripts that must run before the container loads, such as a consent platform that recommends direct installation, and scripts that are part of the site's functionality rather than tracking. Keep those in the template, but still record them in the inventory.

4. What is the difference between the Window Loaded and DOM Ready triggers?

DOM Ready fires once the browser has finished parsing the HTML, so page elements exist but images and other resources may still be downloading. Window Loaded fires after the page and its resources have finished loading. Moving a marketing tag from Page View to Window Loaded lets the page's own content load first. The trade-off is that a visitor who leaves very quickly may not be counted, which is acceptable for most secondary tags.

5. Are Custom HTML tags in Google Tag Manager a security risk?

They can be. A Custom HTML tag can run any JavaScript on every page it fires on, including pages with forms and payment steps. Anyone with publish rights can add one, and a compromised vendor script loaded that way runs with the same access. Keep publish rights to a small group, prefer built-in or gallery templates with declared permissions, review Custom HTML changes before publishing, and consider blocking the tag type where you do not need it.

6. Does server-side tagging remove all third-party JavaScript?

No. Something in the browser still has to collect events and send them, usually a single tag pointing at your tagging server. What server-side tagging can do is replace several vendor scripts with that one stream and let the server forward data to each vendor. Some tools, such as heatmaps, session recording and chat, need to run in the page and cannot be moved. It also brings hosting costs and maintenance, so weigh it against simply removing tags.

7. How do I check whether tags fire before cookie consent?

Open the site in a private window, open DevTools on the Network panel, and load a page without interacting with the banner. Look for requests to analytics and advertising domains and for cookies set in the Application panel. Then use the tag manager's preview mode, which shows each tag, whether it fired and the consent state it saw. Repeat after declining and after accepting each category. This is a technical check, not legal advice.

See every tag on your page

The JavaScript Checker loads your page in headless Chromium, lists the third-party tags it loads with their cost, measures size and execution time for every script and captures console errors, giving you the starting list for a tag audit.

Open JavaScript Checker Fixes โ†’
๐Ÿ’ฌ Got a problem?
Related Guides: All JavaScript Checker Fixes  ·  Fixing Cookie Consent  ·  Fixing Long Tasks  ·  Fixing Oversized JavaScript Bundles  ·  Learning Hub

About aiwebpageseo

aiwebpageseo.com is a data-driven SEO and AEO (Answer Engine Optimisation) platform providing a free suite of technical SEO tools. Rather than relying on AI-theorised assumptions, the platform analyses live URL performance, delivering objective diagnostics, page speed metrics, CLS debugging, and site crawl data alongside actionable technical tutorials.