Analytics and Tracking

Tag Sequencing

A Google Tag Manager setting that makes one tag fire immediately before or after another, with the option to stop if the first one fails.

Quick facts: Tag Sequencing

Category
Analytics and Tracking
Level
Advanced
Affects
Tag firing order, third-party script dependencies, data accuracy
Where to see it
Google Tag Manager advanced settings, GTM preview mode, Tag Assistant
In this article4
  1. How tag sequencing works
  2. Why it matters
  3. Common mistakes
  4. How to act on it

Tag sequencing is a Google Tag Manager setting that makes one tag fire immediately before or after another. You use it when a tag depends on something else having run first, for example a script that must load a library before the main tag can use it.

How tag sequencing works

In the advanced settings of any tag in Google Tag Manager, you can choose a setup tag, a cleanup tag, or both:

  • Setup tag Fires just before the main tag. You can tell GTM not to fire the main tag if the setup tag fails.
  • Cleanup tag Fires just after the main tag. You can tell GTM not to fire it if the main tag fails or is paused.

The main tag’s trigger controls the whole sequence. The setup and cleanup tags do not need triggers of their own; they ride along with the main one.

Success and failure are where it gets technical. GTM’s built-in tag templates report success or failure themselves. A Custom HTML tag reports success as soon as its code is added to the page, unless you write it to signal completion explicitly. If your setup script loads a library asynchronously, GTM may think it has finished before the library is ready, and the main tag still fires too early. Developers handle this by calling GTM’s success and failure callbacks, using the HTML ID built-in variable, once the work is actually done.

Tag sequencing is different from tag firing priority. Priority is a number that sets the order in which tags on the same trigger start, but GTM does not wait for one to finish before starting the next.

Why it matters

Most tracking setups never need sequencing. Where it does help is with dependencies you cannot avoid: a third-party tool that needs a configuration call before it records anything, or a clean-up step that resets a value after a conversion so it does not leak into the next event. Getting the order wrong in those cases produces intermittent errors, which are the hardest kind to diagnose because the tag works on fast connections and fails on slow ones.

It is also worth recognising sequencing when you inherit a container. If a tag will not fire and its own trigger looks fine, check whether another tag names it as a setup or cleanup tag, or whether it is blocked because its setup tag failed. That relationship is only visible in the advanced settings, so it is easy to miss.

Common mistakes

  • Using sequencing for consent. Consent belongs in GTM’s consent settings and consent initialisation trigger, not in a setup tag that tries to check the banner.
  • Assuming Custom HTML waits for async code. It does not, unless you signal success yourself.
  • Confusing priority with sequencing. A higher priority starts a tag earlier but does not guarantee it has finished.
  • Long chains. Sequencing several tags in a row makes the container fragile and hard for the next person to follow.

How to act on it

Before reaching for sequencing, ask whether the dependency can be handled another way. Often the cleaner option is for the site to push a custom event to the data layer once something is ready, and to fire the dependent tag on that event. If you do sequence tags, test in preview mode on a throttled connection, confirm the order in Tag Assistant, and add a note in the tag explaining why.

Untangling fragile containers is a regular part of the tracking work in my performance marketing service.

Do and do not

Do

  • Use it only for genuine dependencies
  • Signal success from Custom HTML tags that load code asynchronously
  • Test on a throttled connection

Do not

  • Use sequencing to manage cookie consent
  • Treat firing priority as a sequence

Questions people ask about this

Should I use tag sequencing to fire GA4 configuration before GA4 events?

No, that is not needed any more. GA4 event tags in GTM handle the Google tag dependency themselves. Make sure the Google tag fires on an initialisation or all-pages trigger and the event tags will work.

What happens if the setup tag fails?

That depends on the tick box. If you chose not to fire the main tag when the setup tag fails, the main tag is skipped. If you left it unticked, the main tag fires anyway, which is sometimes acceptable for non-critical setup steps.

Can a tag be used as a setup tag for several other tags?

Yes. Several main tags can name the same setup tag. Be aware it then fires once for each main tag that fires, so a setup tag that sends data could send it several times on one page.

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.