TRACKING SPECIALIST — BARIS ASA · LONDON
Synctag
Start the check → TRACKING SPECIALIST — BARIS ASA · LONDON

READING ROOM › FIELD NOTE › NOTE-027

NOTE-027 · FIELD NOTE FILED 12 NOV 2026 · REVISED 12 NOV 2026 F-501 F-101 F-103

Cleaning up a messy GTM container: the order to work in without breaking tracking.

ABSTRACT — Clean a Google Tag Manager container in six steps: back up, list and measure, pause dead tags, fix triggers, replace custom code, rename last. One named version per step, checked against your orders after each publish, so any change that moves a number can be found and rolled back.

Baris Asa, Synctag, tracking specialist, London · Last checked: November 2026

Clean a Google Tag Manager (GTM) container in six steps, in this order: back up, list and measure, pause dead tags, fix triggers, replace custom code, rename last. Publish each step on its own and check your numbers against your orders before the next one.

That way, when a number moves, you know which change moved it, and GTM can put the previous version back.

You probably need a clean-up if:

  • GA4 purchases differ from the store’s paid orders by more than a few per cent, or sit at an exact double
  • the Size indicator on GTM’s Versions page is above 70% (Google’s point to start optimising)
  • the tag list still has Universal Analytics tags, which have sent data to nothing since July 2023 (July 2024 for UA 360)
  • nobody can say what half the tags do, or who asked for them

The read-only review that usually comes first, with its keep, fix, remove or add list, is in GTM container audit: what gets checked and what you get back. This note is the work that follows it.

Why does the order matter?

Because a messy container is usually a working one. It sends purchases, leads and remarketing data that ad platforms bid on today, however untidy it looks. The risk is removing a tag something still depends on. You find out a fortnight later, after Google Ads has been bidding on the wrong conversion count.

The order below puts the reversible changes first and the cosmetic ones last. Renaming 200 items in the first week makes every later diff harder to read, so it waits.

StepWhat you doHow you know it held
1. Back upExport the live versionJSON file saved with the date
2. Inventory and baselineList every item; record a week of numbersOne row per tag; baseline filed
3. Dead tagsPause, publish, watch, then deleteBaseline unchanged
4. TriggersFix firing on the wrong event or twiceOne hit per order in Preview
5. Custom codeSwap Custom HTML for templatesSame data, fewer scripts
6. Names and foldersRename, group, write notesA stranger can follow it

Steps 1 and 2 need access to GTM that can export the container (check this first) plus your GA4 and store reports. Steps 3 to 6 need Edit access to make the changes, a Publish user to put each version live, and a test order or test form after each change. “Preview” below is GTM’s test mode: it runs your unpublished changes in your browser, or for anyone you send its share link to.

Step 1: what do you save before changing anything?

The live version, as a file. In GTM go to Admin › Export Container, choose the published version and download it. That JSON file holds every tag, trigger and variable as they are today. File it with the date.

Then check the Versions page. If the live version has a name like “Version 47” and no description, give the next one a proper name. Google’s own advice is a version name and description that make it easy to see what changed.

The file isn’t the rollback. The Versions page is: select an earlier version and choose Publish from its Actions menu. Then choose Set as Latest Version on the same version, so your workspace (GTM’s draft) starts again from the good state rather than the broken one. The file is what you read when you need to know what a deleted tag used to do.

Step 2: what goes in the inventory and the baseline?

The inventory is one row per tag: what it sends, where it sends it, which trigger fires it, and who asked for it. If there was an audit, its inventory is your starting point. If not, build it from the exported file. Tags with no owner and no obvious purpose are the ones to ask about now, before step 3, not after.

The baseline is a week of the numbers the business relies on, written down before the first change:

  • GA4 purchases or key events per day, beside the store’s paid orders or the CRM’s leads
  • conversions per day in Google Ads, by conversion action
  • events received per day in Meta Events Manager, if Meta is in the container

After every publish you compare against this. Without it, “nothing broke” is a guess.

Step 3: how do you remove dead tags safely?

Pause first. Pausing disables a tag without deleting it, so it can be switched back on; Google’s bulk actions pause several at once from the tag list. A pause only reaches the live site once the container is published.

  1. Pause the candidates. Universal Analytics tags are the easy ones: standard UA properties stopped processing data on 1 July 2023, so a UA tag sends hits to nothing.
  2. Publish as a named version (“Clean-up 1: pause 14 dead tags”).
  3. Watch the baseline for at least one full trading week, so weekend and weekday patterns both pass. That’s my rule, not Google’s.
  4. If nothing moved, delete them in the next version. Paused isn’t the end state; pausing is what makes the deletion safe. If something moved, unpause the tag you suspect, publish, and find out what it was doing.

A tag that looks dead can still be load-bearing. A Custom HTML tag (script pasted in by hand, often a vendor’s) may set a cookie another tag reads, or push an event that fires a purchase tag. Tag sequencing (a setting that makes one tag run before another) hides the same kind of link. Read each tag’s settings before pausing it, not just its name.

Then the triggers and variables nothing uses any more. A variable is referred to by its name in double curly braces, so search the exported file for {{variable name}}. A name that only appears in its own definition can go. Triggers are referred to by ID, not name: note each trigger’s triggerId and search the tags’ firingTriggerId and blockingTriggerId; a trigger with no match fires nothing. Google’s guidance is to remove tags and variables that are no longer needed, and to optimise once the Size indicator on the Versions page passes 70%.

Step 4: which triggers do you fix first?

The ones that change numbers ad platforms bid on:

  • A purchase tag firing on page load instead of on the order event the site pushes to the dataLayer (the order details the page hands to GTM), so value or products are empty on some orders. Fault F-103; the timing fix is in GTM tag fires before the dataLayer is ready.
  • A purchase sent twice, by two triggers on one tag, or by a GTM tag and a Google tag hard-coded in the theme. GA4 drops a repeat purchase with the same transaction ID (the order number). Google Ads does the same within one conversion action (the conversion it bids on). The order counts twice when the ID is missing or differs, or when the copies go to different conversion actions. Fault F-101; worked through in GA4 purchase event fires twice.
  • A broad trigger doing a narrow job. An “All clicks” or “All pages” trigger with a long list of exceptions is easier to break than one written for the page or button it means.

One trigger change per version. Test each in Preview before publishing: Tag Assistant shows which tags fired, in which order, and which trigger did or didn’t fire them. If Preview won’t connect, the usual causes are in GTM Preview not connecting. For a purchase, place a real or test order and confirm one hit leaves the page, with the order number, value and products in it.

Step 5: when do you replace Custom HTML?

After the numbers are steady. A template is a ready-made tag type in GTM’s gallery, filled in with settings rather than code. Google says a supported template is in most cases more efficient than custom code, and recommends built-in templates, triggers and variables wherever possible.

Swap one at a time:

  1. Build the template tag beside the Custom HTML one, in the workspace.
  2. In one Preview session, compare what both send, in Tag Assistant and the browser’s network panel (the list of requests the page makes). Both tags fire, so each hit appears twice, once from each. These are real hits sent to the platforms, so use a test order or test form.
  3. Once they match, pause or delete the Custom HTML tag and publish the swap as one version.

If the template can’t send something the old tag did, write that down and keep the custom tag until someone decides it’s no longer needed.

Ten near-identical tags (one per page, one per market) can often become one tag whose value comes from a lookup table variable; Google’s example does exactly that.

Step 6: names, folders and notes

Names, folders and notes. Nothing that fires differently.

  • Names. Google suggests <item type> - <name of app> - <detail> for tags, triggers, variables, versions and workspaces, for example “GA4 event - Shop - purchase” or “Custom event - Shop - purchase”. Pick a pattern and use it everywhere.
  • Folders. By platform (GA4, Google Ads, Meta, other), by team, or by project. Selected items move to a folder in one action.
  • Notes. Each tag gets a line on why it exists and who asked for it, and the workspace description says what is in progress.

Renaming in its own version keeps it reviewable: the version diff shows names changing and nothing else. That’s the record fault F-501 is about. The next person starts from a container they can read.

What should you not do during a clean-up?

  • Don’t import a container with Overwrite. It removes every existing tag, trigger and variable and replaces them with the imported file. Overwriting with an empty container is how some guides “reset” GTM; on a live site it removes the purchase tags too. Merge, or work by hand.
  • Don’t run it across several workspaces. A standard container has the default workspace and up to two more. When one publishes, the others go out of date and conflicts have to be resolved item by item. Keep the clean-up in one.
  • Don’t change the site’s dataLayer in the same week. If the developer changes what the page pushes while you change the tags that read it, a gap can’t be traced to either.
  • Don’t publish on a Friday before peak trading. Black Friday week is for watching, not for clean-ups.

Who does the clean-up?

An in-house developer or analyst can do all six steps with this order and a baseline. Whoever holds Publish access in GTM puts each version live.

Bring someone in when nobody can say what half the tags do (start with the audit), when the container feeds bidding on a large ad budget and nobody wants to own the risk, or when an agency needs the work done inside a client’s container under its own name.

I’m a tracking specialist in London and do this as Google Tag Manager consultant work for UK brands and the agencies behind them, small containers included. I work in a workspace and publish one named version per step. You get back the inventory, the baseline comparison after each publish and the export of the version before I started, so every change is on record. Scope and timing are agreed on a short call, once I’ve seen the container.

Common questions

Should I start a new GTM container instead of cleaning the old one?

Usually not. A new container means a new snippet on every page, new user permissions and no version history, and every tag still has to be rebuilt and tested. Cleaning in place keeps the rollback path. A rebuild makes sense when the container’s logic can’t be followed or the site is being rebuilt anyway.

Can the clean-up run while an agency is also working in the container?

Yes, if everyone knows. Each person works in their own workspace. When one publishes, the other workspaces are marked out of date and must be updated, and any item both people changed shows as a conflict to resolve. Agree who publishes and when, so a clean-up version and a campaign launch don’t go out on the same afternoon.

How do I find variables that nothing uses?

Export the container and search the JSON file for each variable’s name in double curly braces, for example {{DLV - order value}}. Tags, triggers and other variables refer to a variable that way. A name that only appears in its own definition is a candidate for removal; built-in variables are switched on and off rather than deleted.

Should paused tags stay in the container?

No. Pausing is the step that makes deletion safe, not the end state. Once the numbers have held for a full trading week, the paused tags are deleted in the next version. The old version still holds them if anyone needs to see what they did.

Sources

Read on 12 November 2026:

  • Google Tag Manager Help, export and import containers (Admin › Export Container, version or workspace; Overwrite removes existing tags, triggers and variables; Merge with overwrite or rename conflicts)
  • Google Tag Manager Help, publishing, versions and approvals (version name and description; publish an earlier version from Versions › Actions; Set as Latest Version; Approve or higher creates versions)
  • Google Tag Manager Help, workspaces (up to 2 additional workspaces on standard accounts; out-of-date workspaces and conflicts)
  • Google Tag Manager Help, user permissions (Read, Edit, Approve, Publish)
  • Google Tag Manager Help, pause tags and bulk actions (pausing temporarily disables a tag without deleting it; save and publish for it to take effect; pause many tags, move to folder)
  • Google Tag Manager Help, get started (Size indicator above 70%; remove unneeded tags and variables; one tag with a Lookup Table variable; templates over custom code)
  • Google Tag Manager Help, organise your container (folders by project, team or type; naming pattern <item type> - <name of app> - <detail>)
  • Google Tag Manager Help, preview and debug containers (which tags fired and in which order; why a trigger did or didn’t fire)
  • Google Analytics Help, Universal Analytics is going away (standard properties stopped processing data on 1 July 2023)
  • Google Analytics Help, purchase deduplication with transaction ID and Google Ads Help, transaction IDs to avoid duplicate conversions

— B.A., filed from London

CONNECTED RECORDS F-501 F-101 F-103

REVISION HISTORY — revised 12 NOV 2026.

← back to the reading room