Blog

The tag firing order most teams get wrong

GTM does not guarantee firing order by default. Three patterns where this matters and the settings that fix it.

By default, GTM fires tags in parallel. This is fast and usually correct. There are three specific cases where it is wrong, and where teams notice intermittent failures that they cannot reproduce.

Case 1: a tag depends on a previous tag's side effect

If Tag A sets a cookie that Tag B reads, and they both fire on the same trigger, B may run before the cookie is set. The result: B reads an empty cookie, behaves wrong, and there is no error.

Fix: in Tag B's advanced settings, set "Fire a tag before this tag" to A. Now B waits for A to complete (success or failure) before running.

Case 2: dedup ID generation must precede the tags that use it

For event_id-based dedup, the ID must be generated before any tag that uses it. If the ID is generated in a tag (rather than the data layer push), and that tag fires in parallel with the consumers, the consumers will sometimes get an empty ID.

Fix: generate the ID in the data layer push (as part of the page-side code), not in a tag. The push happens before any tag fires.

Case 3: consent state must be set before any consent-gated tag

If your consent management tag and your tracking tags share a trigger, the tracking tags can fire before the consent state is updated. They will see the previous state, which is usually "denied," and skip.

Fix: the consent management tag has its own trigger (typically a custom event fired by the CMP after the user interacts with the banner). Tracking tags trigger on a different event that fires only after consent is established.

The "Fire a tag before this tag" setting

In any tag's Advanced Settings, you can specify a setup tag (must complete first) and a cleanup tag (fires after). The cleanup tag is rarely useful; the setup tag is the workhorse.

Use it sparingly. Each dependency adds latency. The right tool for two-tag dependencies; the wrong tool for chains of five.

When sequencing is not the answer

If you find yourself building a chain of dependent tags, consider whether the work belongs in a single tag or in a custom template that does multiple things. The flexibility of multiple small tags has a cost in firing-order assumptions.

Diagnosing order issues

In GTM Preview Mode, the "Tag Sequencing" view shows which tags fired in which order, including which ones waited for setup tags. If you suspect order is the issue, this is the view that proves or disproves it.