Analytics and Tracking

Tag Sequencing

Also called Setup and cleanup tags

A setting that links tags so one finishes before another begins, with an optional cleanup tag after.

Quick facts: Tag Sequencing

Category
Analytics and Tracking
Also called
Setup and cleanup tags
Level
Advanced
Affects
Conversion accuracy, data completeness, debugging effort
Where to see it
Google Tag Manager (tag advanced settings), Preview mode
In this article4
  1. How tag sequencing works
  2. Why it matters
  3. Where tag sequencing goes wrong
  4. Getting it right

How tag sequencing works

Open any tag in Google Tag Manager, look in its advanced settings, and you can nominate two companions: a setup tag that runs before it, and a cleanup tag that runs after it. The three then behave as one unit. The setup tag fires first and is allowed to finish, the main tag fires next, and the cleanup tag follows.

There is one option worth understanding. You can tell Tag Manager not to fire the main tag if the setup tag fails, which turns a loose ordering into a genuine dependency. Without it, a broken setup tag lets the main tag run anyway, on whatever incomplete information happens to be available.

Why it matters

Some tags need something to exist before they can do their job. A conversion tag that reads a value assembled by a small script needs that script to have run. A vendor tag that depends on a library needs the library loaded. Without sequencing, the browser fires everything attached to the same event at roughly the same moment and the order is not something you can rely on.

The symptom of getting this wrong is quietly misleading rather than obviously broken: conversions that record with a missing value, events that arrive without the details that made them useful, or figures that are correct on a fast connection and wrong on a slow one. That last case matters on mobile networks, where the gap between two tags is wider than it looks on an office connection.

Where tag sequencing goes wrong

The first trap is a setup tag that also has its own firing trigger. It will then fire twice on the same page — once on its own trigger, once as part of the sequence — and if it is anything that counts, you have just doubled it. Setup tags are usually best left with no trigger of their own.

The second is chaining. A sequence of several tags, each depending on the last, is very hard to reason about and worse to debug months later. And sequencing is often used to paper over a timing problem that should be fixed at source: if a value is not ready when the tag needs it, the durable answer is for the site to announce it properly rather than for Tag Manager to wait and hope.

Getting it right

Use sequencing only for a real dependency, keep it to a pair, and switch on the option that stops the main tag when the setup tag fails — an absent conversion is easier to spot than a wrong one. Where the dependency is really about data, ask for the value to be pushed into the data layer before the event fires; that removes the need for sequencing altogether.

Do not confuse it with tag firing priority, which only decides the order in which tags start and never waits for one to finish. Verify every sequence in Preview mode on a slow connection as well as a fast one, because a race condition that never appears in the office will appear on somebody’s phone.

Do and do not

Do

  • Use sequencing only for a genuine dependency
  • Leave setup tags without a trigger of their own
  • Stop the main tag when the setup tag fails

Do not

  • Chain several tags together in one long sequence
  • Use sequencing to hide a fixable timing problem
  • Confuse it with firing priority, which never waits

Questions people ask about this

What is the difference between tag sequencing and firing priority?

Priority decides the order in which tags begin, and nothing more; a tag that starts first can still finish last. Sequencing links tags into a unit, so the setup tag completes before the main tag begins. If a tag genuinely depends on another having finished, priority will not give you that guarantee and sequencing will.

Should the setup tag have its own trigger?

Usually not. If the setup tag has a trigger of its own as well as being part of a sequence, it can run twice on the same page, which duplicates anything it counts or sends. Leave setup tags untriggered so the sequence is their only route to firing, and check in Preview mode that each one appears exactly once.

What happens if the setup tag fails?

By default the main tag still fires, working with whatever information is available, which can produce a conversion that looks fine but carries the wrong value. There is a setting that prevents the main tag firing when the setup tag fails. Switch it on for anything that reports money or leads, since a missing record is easier to notice than a wrong one.

Related terms

Found this useful?

Share it, or ask an AI to summarise it

Back to the glossary

Knowing the term is the easy part

Applying it to your own site and budget is the work. Book a call and I will tell you what actually applies to you.