Skip to content

Cleanup tags in GTM: the tidy-up pass that keeps your conversion data honest

IH
Ian H
24 Aug 2026 · 6 min read
Share
A blue bowling-lane sweeper bar descending across the pin deck, pushing aside three toppled pins to clear the lane before the next frame.

Your tracking probably isn't broken. It's just untidy. A cleanup tag in Google Tag Manager is a tag that fires automatically the moment another tag finishes, and it's how you fix that. You don't give it a trigger. You attach it to the main tag, and GTM runs it straight afterwards.

That's the whole idea. It's the tidy-up pass — ten minutes of setup that protects every report you'll read for the next year. It's also one of the few GTM habits with a UK consent angle attached, which is where most guidance on this goes quiet.

What is a cleanup tag in Google Tag Manager?

Cleanup tags are one half of a feature called tag sequencing. The other half is the setup tag, which fires before your main tag. You configure both on the main tag itself: Advanced Settings → Tag Sequencing, then tick "Fire a cleanup tag when [tag] is finished" and pick the tag you want.

Two things worth knowing:

  • Neither the setup nor the cleanup tag needs its own trigger. GTM fires them in sequence for you.
  • There's a second checkbox — "Don't fire [cleanup tag] if [tag] fails" — so cleanup only runs when the main tag actually succeeded. Google's tag sequencing documentation covers both options.

Why does a cleanup tag matter for your reporting?

The most common reason people reach for one: clearing data layer values after a tag has read them.

Values pushed into the data layer stick around. Say a form submission pushes lead_type: "quote" and nothing clears it. That value is still sitting there when the next event fires — so a later event inherits a label that belongs to something that happened five minutes ago.

Nothing breaks. No error appears. The numbers just quietly drift, and by the time someone questions a report, you've been optimising against slightly wrong figures for months. A cleanup tag resets the value the instant the tag that needed it has finished with it.

One specific worth having: Google's documentation notes that when you change data layer values inside a sequence you should use google_tag_manager[{{Container ID}}].dataLayer.set() rather than .push(), so the change applies to the event currently being processed.

Why do landing page forms lose their attribution data?

Here's the version that costs real money.

Your tracking catches the URL parameters when someone lands — gclid, the UTMs, whatever you're passing — and writes them into hidden fields on the form, so the lead arrives in your CRM already labelled with where it came from.

Except those values often aren't ready when the form is there to be filled in. The capture happens, but the injection into the hidden fields doesn't reliably land until the second page load. So the visitor who arrives on your landing page and fills the form in there and then — the keenest one, the one you paid most to get — submits with those fields empty. Real lead. Blank source.

Sequencing fixes it. The cleanup tag only runs once the tag that captured the parameters has confirmed it's finished, so the injection can't run early and the fields are populated from the first page load. On a landing page, where plenty of conversions happen without a second pageview ever loading, that's the difference between attribution you can optimise on and a pile of leads you can't trace.

"First page load" does not mean "before the consent banner". Capturing a click ID for attribution is an advertising purpose, and the ICO is blunt about where that stands: "If your service uses storage or access technologies for the purposes of online advertising, you must get consent. You cannot rely on any of the exceptions." Its guidance on exceptions names ad measurement and performance explicitly, and states there are no advertising purposes that meet the strictly necessary exception.

The ICO's guidance on storage and access technologies even works through this exact pattern — a platform appending a unique ID to the URL, the advertiser storing it in a first-party cookie — and concludes regulation 6 applies.

So gate the sequence properly. GTM's Consent Initialization trigger "will always fire before all other tags", and setting a tag to require additional consent means it "will only fire if the status of all specified consent types are 'granted' when the tag is triggered". Do that, and you're fixing the order your tags run in once you're allowed to run them — not running them sooner than you should. None of this is legal advice; if you're unsure how your banner and your CRM fit together, get it checked properly.

Where else do cleanup tags earn their keep?

  • Resetting data layer variables after a tag has read them — far and away the most common use.
  • Removing temporary cookies, globals or DOM elements that a setup tag created just to get the main tag over the line.
  • Firing a secondary pixel that has to run strictly after the main one, rather than racing it.

Three things that catch people out

Custom HTML tags have to announce they've finished. GTM waits for a callback before moving on. As Simo Ahava puts it in his guide to tag sequencing with Custom HTML tags, if that callback is never invoked, the "sequence will never proceed to the next tag". The chain stalls, silently.

A cleanup tag with its own trigger can fire twice. Ahava's broader explainer on tag sequencing points at the "Once per event" firing option to stop that. Simpler still: if a tag only exists to run in the sequence, don't give it a trigger at all.

No main tag, no cleanup. If the primary tag is paused or its trigger never fires, the cleanup tag doesn't fire either. So don't hang anything on it that has to happen regardless.

Is it worth the effort?

On a simple container, no. You'd spot the mess. But anything with multiple conversion types, a CRM push, or a landing page leaning on hidden fields, and the sequence is doing real work on every single session. Accurate conversion measurement is the foundation the rest of the account sits on, which is why it's built into how we run PPC management rather than treated as a one-off setup job.

Tidy up after your tags, and your reports stop drifting.

Not sure whether your conversion data is telling you the truth? Get in touch and we'll take a look under the bonnet.

Sources

FAQs

No. GTM fires it automatically once the main tag finishes. Giving it a trigger as well risks it firing twice.

A setup tag fires before the main tag, usually to prepare something it needs. A cleanup tag fires after, usually to clear that something away. You configure one of each on the main tag.

Only if you let it. Tick "Don't fire [cleanup tag] if [tag] fails" and it runs on success only.

If you store anything on the visitor's device to do it, yes. The ICO treats ad measurement and attribution as an advertising purpose, and advertising has no exemption under PECR. Put the sequence behind your consent banner.

Keep reading

More from the team.

All articles
More Leads. Better Customers. Faster Growth.