How to Gate GTM Tags with Captain Compliance Consent Events (Advanced)

Edited

Native consent settings decide whether a tag may fire; they can’t make a tag fire at a new moment. When you need that, for example to fire a tag the instant a visitor clicks Allow without waiting for the next page, or to run different logic for different consent states, you can build triggers directly on the events Captain Compliance pushes to the data layer. This article explains the events, the variables to read them with, and the trigger patterns that use them.

Use this approach for the specific tags that need it, alongside native consent settings for everything else. It’s more to build and more to maintain, and it’s rarely needed for a whole container.

The events

The banner pushes these events to the data layer:

  • captainComplianceConsent: the visitor’s consent state. Pushed on page load when a stored choice exists, and again whenever the state changes. Carries the active model and a selectedCookies object with one boolean per category.

  • captainComplianceConsentUpdated: pushed when the visitor actively makes or changes a choice in the banner. Carries the same payload.

  • captainComplianceConsentReady: pushed once the banner has resolved the visitor’s effective state for the page (regional default, stored preference and GPC). Carries no decision of its own; it marks the moment the state is known.

The Captain Compliance CMP tag also keeps the Google Consent Mode signals in sync with these, so a tag’s native consent setting still applies even when it fires from one of these events. That’s useful: the event supplies the timing, and the consent setting supplies the enforcement.

The variables

Create one Data Layer Variable (version 2) per category you need:

Variable name

Data Layer Variable Name

CC - Performance granted

selectedCookies.PERFORMANCE_COOKIES

CC - Targeting granted

selectedCookies.TARGETING_COOKIES

CC - Functionality granted

selectedCookies.FUNCTIONALITY_COOKIES

Each returns true when the category is granted at the time the event fires. Reading them at any other time gives you the value from the most recent consent event on the page.

Pattern 1: Fire the instant the visitor allows

A tag that should start the moment a visitor clicks Allow, and also run normally on later pages, needs two triggers.

  1. Create a Custom Event trigger on captainComplianceConsentUpdated, firing on Some Custom Events, with the condition for the category, for example CC - Targeting granted equals true. Name it CC - Consent Updated - Targeting.

  2. Give the tag that trigger plus CC - Consent Ready, the trigger used for early-firing tags.

  3. Keep the tag’s native consent setting (Require additional consent with the matching category). It blocks the Consent Ready firing when the stored state is denied, and it’s harmless on the update firing because the category is granted by then.

On a cold load in an opt-in region, Consent Ready fires with consent denied and the tag is blocked. The visitor clicks Allow, the update trigger fires and the tag runs. On the next page, Consent Ready fires with the stored choice and the tag runs.

Set the tag’s firing option to Once per page if it must not run twice on a page where the visitor both had consent and changed it.

Pattern 2: React to a withdrawal

To run something when a visitor withdraws consent, such as clearing a vendor’s identifiers:

  1. Create a Custom Event trigger on captainComplianceConsentUpdated with the condition CC - Targeting granted equals false.

  2. Put the cleanup tag on it, with its consent setting at No additional consent required, since it must run precisely when consent is denied.

Pattern 3: Branch on a category inside a trigger

Any existing trigger can take a consent condition. Add CC - Performance granted equals true to a trigger’s conditions, and the tags on it are evaluated against the latest consent event rather than the Google Consent Mode state. This is mostly useful for tags you deliberately keep at No additional consent required but still want to behave differently by category, for example a Custom HTML tag that sends a reduced payload when Targeting is denied.

Combining with native settings

Keep these rules so the two mechanisms don’t fight:

  • Every tag still gets a native consent setting. Event-based triggers change when a tag is evaluated; the consent setting decides whether it runs. The only exception is a tag whose job is to run on denial (Pattern 2).

  • Don’t put tags on the Captain Compliance events with a catch-all pattern. A trigger matching .+ fires on Consent Initialization too, before the state is applied.

  • Keep the Captain Compliance CMP tag on Consent Initialization only, and Google tags on Initialization or later. Neither belongs on these events.

Verify

In Preview, run the opt-in default load, click Allow without reloading, and confirm the tag fires on captainComplianceConsentUpdated with the category variable showing true. Reload and confirm it fires on captainComplianceConsentReady. Then run the Reject case and confirm it fires on neither. The testing article has the full grid.

Related articles