Integration
CookieBoss for Google Tag Manager
The CookieBoss tag template loads your consent banner from Google Tag Manager and runs Google Consent Mode v2 for it. Your Google tags get a denied default before they fire, and an update as soon as the visitor decides.
What the template does
- Sets the defaults. Every consent type except
security_storagestarts asdenied, withwait_for_updateat 500 ms so Google tags wait briefly for the banner. - Applies a returning visitor's choice immediately. It reads the
cookieboss_consentcookie and sends a Consent Mode update before the banner script has loaded, so tags on the page do not wait. - Loads the banner. It injects your site's script from
cdn.cookieboss.io, the same file the script tag would load. - Follows every choice. When the visitor accepts, rejects or saves preferences, the template sends a Consent Mode update with the result. If a stored choice has expired, or you have asked visitors to consent again, it reverts to denied.
Category mapping
Each Google consent type is granted when the visitor accepts the CookieBoss category next to it. You can change the mapping in the tag's Category mapping section.
| Consent type | CookieBoss category |
|---|---|
| ad_storage | Marketing |
| ad_user_data | Marketing |
| ad_personalization | Marketing |
| analytics_storage | Analytics |
| functionality_storage | Functional |
| personalization_storage | Functional |
| security_storage | Always granted |
Regional defaults
Add a row per group of regions, using ISO 3166-2 codes such as US or US-CA, and
choose granted or denied for each consent type. Google applies the most specific matching region, so a row
for US-CA overrides one for US, and both override the global default. Only set a
type to granted where the law that applies to those visitors allows it before a choice.
Setup
- 1
Hand Consent Mode to the template
In the CookieBoss dashboard, open the banner editor for your site, switch off Google Consent Mode v2 on the Behaviour tab and publish. Remove any CookieBoss script tag you added to the page yourself: the template loads the script.
- 2
Add the template to your container
In Google Tag Manager, go to Templates, then Tag Templates, Search Gallery, and add CookieBoss Consent Mode. Until the gallery listing is live, download the template file below and use New, then Import, instead.
- 3
Create the tag
Under Tags, create a tag of type CookieBoss Consent Mode and enter your Site ID (shown for each site in the dashboard). Optionally add regional defaults, URL passthrough or ads data redaction.
- 4
Fire it first
Set the trigger to Consent Initialization - All Pages. This trigger runs before every other trigger, so the defaults are in place before any Google tag reads them.
- 5
Preview, then publish
Open Preview. In Tag Assistant, the Consent tab should show the defaults as denied on the first event and an update after you choose in the banner. Then publish the container.
Questions
Why switch off Consent Mode in CookieBoss when using the template?
With Consent Mode on, the CookieBoss script sends its own default and update commands. The template sends the same signals earlier, from the Consent Initialization trigger, and adds regional defaults and a configurable mapping. With the default mapping both send the same updates, so leaving both on does no harm; with a changed mapping they would contradict each other. Either way, one source of Consent Mode commands is easier to reason about and to debug, so with the template, let the template own Consent Mode.
How do I check that Consent Mode works?
Use Tag Assistant's Consent tab in Preview: the first event should show the defaults, and the event after
your banner choice should show the update. To confirm that Google received it, look at a Google Analytics
request (/g/collect) in the browser's network panel: its gcs parameter is
G100 when ad and analytics storage are denied and G111 when both are granted.
Can I still use the dataLayer events?
Yes. If GTM events are enabled in CookieBoss, the script still pushes
cookieboss_consent_update and the other events for tags that are not Google tags. See the
GTM documentation for triggers and
variables.
Does the template block non-Google tags?
No. Consent Mode applies to Google tags and tags that read it. For other tags, use GTM's built-in consent settings (Additional consent checks) or the CookieBoss dataLayer events as triggers.