GTM Tag Sequencing: Setup, Cleanup and Firing Order
Tag sequencing makes one Tag Manager tag fire right before or right after another. This guide covers setup and cleanup tags, the option to stop a tag when the one before it fails, how Tag Manager knows a tag failed, firing priority and the once per event and once per page options.
This guide is built from Google's own pages, checked on 10 November 2026: Tag Manager Help on tag sequencing, tag firing options and built-in variables, the Tag Manager API reference for the Tag resource and Google's developer guide to custom templates. How triggers decide when a tag fires is in our GTM triggers guide; how values reach the data layer is in the data layer guide.
What tag sequencing does
Normally each tag fires when its own triggers match, and tags that match the same event run side by side. Sequencing ties two tags together. Google's definition: tag sequencing "enables you to specify tags to fire immediately before or after a given "primary" tag is fired."
The setting lives on the primary tag. Google says it "is available in web containers, and may be applied to any tag configuration from Advanced Settings". The section is called Tag Sequencing. Two roles come out of it:
| Setup tag | Cleanup tag | |
|---|---|---|
| When it fires | "before the primary tag" | "immediately after the primary tag" |
| Checkbox on the primary tag | Fire a setup tag before <this tag> fires | Fire a cleanup tag when <this tag> is finished |
| Optional failure rule | Don't fire <this tag> if <setup tag> fails | Don't fire <cleanup tag> if <this tag> fails |
| Name in the API | setupTag, with stopOnSetupFailure | teardownTag, with stopTeardownOnFailure |
| How many | One of each. The API reference says of both lists: "Currently we only allow one." | |
The setup and cleanup tags are tied to the primary tag: they fire before and after it, when it fires, so the sequence follows the primary tag's triggers.
Setup tags
A setup tag prepares something the primary tag depends on: loading a vendor library, setting a value, or initialising an object. Google's steps, on the primary tag:
- Open Advanced Settings, then Tag Sequencing.
- Select the "Fire a setup tag before <this tag> fires" checkbox. Tag Manager shows your tag's name in place of <this tag>.
- Select the tag to use from the menu.
- Optionally select "Don't fire <this tag> if <setup tag> fails", if you want the main tag "only fire when the setup tag fires successfully."
One detail matters for developers. If the setup tag changes a data layer value that the primary tag reads, Google says to use google_tag_manager[{{Container ID}}].dataLayer.set() rather than a push: "You need to use .set() instead of .push() because the .push() won't get recognized by Google Tag Manager until the following event." A push is queued behind the current event, which our data layer guide explains under order and timing.
Cleanup tags
A cleanup tag runs after the primary tag is done: resetting a value, removing a temporary element, or sending a follow-up hit. The steps mirror the setup ones:
- Select the "Fire a cleanup tag when <this tag> is finished" checkbox.
- Select the tag to use from the menu.
- Optionally select "Don't fire <cleanup tag> if <this tag> fails", so the cleanup tag only fires when the primary tag succeeded.
The API reference states the two choices plainly: with the option on, "fire the teardown tag if and only if the main tag fires successfully"; with it off, "fire the teardown tag regardless of main tag firing status."
How Tag Manager knows a tag failed
The "fails" options only work if a tag reports success or failure back to Tag Manager. How that happens depends on the tag type:
- Built-in tags and custom templates. Template code calls
data.gtmOnSuccessordata.gtmOnFailure. Google's template guide says these "tell Google Tag Manager when the tag has completed or failed its task, and are then used by Google Tag Manager for features such as tag sequencing or preview mode." - Custom HTML tags. Google lists a built-in utility variable for this, HTML ID, which "Allows custom HTML tags to signal if they had succeeded or failed; used with tag sequencing." Enable it in the built-in variables list (see our GTM variables guide) before you rely on a Custom HTML tag's result.
If a template never calls either function, Tag Manager has no result to act on, and a sequence that waits on it may not behave the way you expect. Check the order and status in preview mode before publishing.
Tag firing priority
Priority is a separate setting with a smaller job. It orders tags that fire on the same event. The API reference describes it: "Tags are fired asynchronously in order of priority. Tags with higher numeric value fire first. A tag's priority can be a positive or negative value. The default value is 0."
The word "asynchronously" is the point. A tag with priority 10 starts before a tag with priority 0, but Tag Manager doesn't wait for it to finish. If tag B needs something tag A loads, priority alone doesn't guarantee it is there in time. Sequencing does wait: the primary tag fires after the setup tag, and with the fails option on, only if it succeeded.
Tag firing options
Also under Advanced Settings, Tag Firing Options control how often a tag may fire. Google lists three:
| Option | Tag Manager Help | API reference |
|---|---|---|
| Unlimited | "Tags will fire whenever triggers tell it to." | "Tag can be fired multiple times per event." |
| Once per event | "The tag will fire only once when the specified event occurs." | "Tag can only be fired per event but can be fired multiple times per load" |
| Once per page | "The tag will fire only once, when the page loads." | "Tag can only be fired per load (e.g., app load or page load)." |
These options matter for sequencing because a setup tag can be shared. Google's example for Once per page is "to load an external JavaScript library, which only needs to happen once when the page loads." If three tags all use the same library-loading tag as their setup tag, Once per page on that setup tag keeps the library from loading three times. Once per event, Google says, helps "when you need to prevent multiple pieces of the same data from being added to the data layer."
Sequencing, priority or a trigger?
This is our reading of Google's settings, not a rule from Google:
| You need | Use |
|---|---|
| Tag B must run after tag A has finished, on the same event | Tag sequencing, A as setup tag of B |
| Tag B must not run if tag A failed | Sequencing with the "Don't fire ... if ... fails" option |
| Rough start order among tags with no dependency | Tag firing priority |
| Tag B should run on a later event, such as a form submission or a value arriving | A separate trigger on that event (see GTM triggers) |
| A shared library or setup step should run once per page | Setup tag set to Once per page |
How we use sequencing
This is our own practice, not Google guidance:
- We prefer a built-in tag or a template over a Custom HTML tag with a setup tag. Fewer custom pieces means fewer silent failures.
- When we do sequence, we name setup tags clearly (for example "Setup - vendor library") so it is obvious they are not meant to fire alone.
- We turn on the fails option when the primary tag can't work without the setup tag, so a broken library doesn't produce half-sent or wrong data.
- We don't use priority to fix a dependency. If order matters, it gets a sequence or its own event.
- Every sequence is checked in preview mode before we publish, and the version description says which tags are sequenced (see our workspaces and versions guide).
Frequently asked questions
What is tag sequencing in Google Tag Manager?
A tag setting that fires another tag immediately before or after a primary tag. The tag before is the setup tag, the tag after is the cleanup tag. It is available in web containers under Advanced Settings, Tag Sequencing.
How many setup and cleanup tags can a tag have?
One of each. The Tag Manager API reference says of both lists: "Currently we only allow one."
Does the setup tag need its own trigger?
No. It fires because the primary tag fires. If you need it to fire before several tags, set it as the setup tag on each of them.
Is tag firing priority the same as tag sequencing?
No. Priority only orders tags that fire on the same event, and Google says they fire asynchronously, so a higher priority tag can start first without finishing first. Sequencing waits for the setup tag before the primary tag fires.
What does Once per page mean in GTM?
The tag fires only once while the page is loaded, even if its trigger matches again. Google's example is loading an external JavaScript library that only needs to load once.
For more on tagging, see our guides to Google Tag Manager basics, GTM environments, server-side tagging and GA4 DebugView.