Consentl with Google Tag Manager
A Google Tag Manager template, imported by hand, that sets Consent Mode v2 defaults per region and, on Pro and higher, forwards each choice to your Google tags.
- Loader first in <head>
- Depends on the method
- Download
- consentl-gtm-template-1.2.1.tpl · Version 1.2.1 · 41 KB · SHA-256
The Consentl template for Google Tag Manager (GTM) owns Google Consent Mode v2 for your site:
- It sets Google Consent Mode v2 defaults per region, before any other tag runs.
- It loads the Consentl banner (optional) and forwards the visitor's choices to Consent Mode: a returning visitor's choice as soon as the banner has run, then every change.
Consent Mode needs the Pro plan or higher. The template reads your plan and the dashboard's Google Consent Mode v2 switch from the banner: it forwards the visitor's choices only when your plan includes Consent Mode and the switch is on. On Free it still sets your defaults but never sends an update (see Plans).
Which setup to choose
| Setup | Holds back non-Google trackers (Business plan) | Consent Mode (Pro plan) |
|---|---|---|
Snippet first in <head>, no template (recommended, see Any website) |
Yes, from the start of the page | Set by the banner |
Snippet in <head> with &gcm=ext plus this template with "Load the banner" unticked |
Yes | Set by the template; useful when GTM is your single source of tag configuration |
| This template only (sites where you can only add GTM) | Only tags added after the banner loaded | Set by the template |
When the template loads the banner, GTM injects it asynchronously, so trackers hard-coded in the page HTML run, and are requested, before it. Tags managed inside GTM are fine: they wait for Consent Mode.
One source of Consent Mode (gcm=ext)
When the template loads the banner, it adds gcm=ext to the banner URL: the banner then sends no
Consent Mode commands of its own and never holds back Google tags. If the snippet is in your page as
well, add &gcm=ext to its URL yourself:
<script src="https://api.consentl.com/v1/loader.js?k=SITE_KEY&l=LANG&gcm=ext"></script>
Without it the page gets two sets of defaults, and the banner's Consent Mode settings from the dashboard apply as well.
Install
- Add the template to your container:
- Community Template Gallery (once published): Templates → Tag Templates → Search Gallery → "Consentl" → Add to workspace.
- Manual import (available now): download the template file from
Downloads, then Templates → Tag Templates → New → ⋮ → Import → choose
the
.tplfile → Save.
- Create the tag: Tags → New → Tag configuration → Consentl Cookie Consent (Consent Mode v2).
- Site key: from your site's Setup page in the Consentl dashboard.
- Banner language: optional, for example
{{Page Language}}. - Load the Consentl banner from this tag: untick it if the snippet is already in
<head>(with&gcm=ext). - Consent Mode defaults: one row per group of regions, mirroring your region rules in the
dashboard, including the rule for all other regions. Use ISO 3166 codes (US states are
written
US-CA). The shortcutsEU(the 27 member states),EEA(the EU plus Iceland, Liechtenstein and Norway) andUK(the same asGB) work too. Example:EEA, GB, CHall denied, plus a row with an empty region for the rest of the world. With no rows, everything is denied everywhere, which is the safest choice.
- Triggering: Consent Initialization – All Pages. This is the only trigger that runs before every other tag.
- In Admin → Container settings, enable Consent overview, and make sure every tag has the
right built-in consent checks or Additional consent settings (for example
ad_storagefor Meta, TikTok and other advertising pixels). - Preview (Tag Assistant) → Consent tab: you should see defaults on Consent Initialization (once) and an update after accepting.
- Submit / Publish.
Events you can trigger tags on
| Event | When |
|---|---|
consentl_consent |
On every page view once the visitor's region is known, and after every choice |
consentl_update |
Only when the visitor makes or changes a choice |
Both carry consentl.preferences, consentl.analytics, consentl.marketing, consentl.sale,
consentl.stored (the visitor has decided) and consentl.region. To fire a tag once the visitor has
agreed, use consentl_update, or consentl_consent with a condition on consentl.stored.
Plans
The banner tells the template whether your plan includes Consent Mode (Pro and higher) and
whether the switch Regions → Google Consent Mode v2 → Send consent signals to Google tags is on.
With gcm=ext the switch changes nothing else, so leave it on when you use this template.
| Situation | What the template does | What Google tags in your container get |
|---|---|---|
| Pro and higher, switch on | Defaults, then the visitor's choices | The visitor's choice |
| Free (snippet first, or banner loaded by the template) | Your defaults (with no rows: everything denied), never an update; Tag Assistant's console shows a hint | Your defaults for good, also after the visitor accepts: where your rows deny, tags with consent checks do not fire, and Google tags in advanced mode only send cookieless pings |
| Pro and higher, switch off, snippet first | Nothing; Tag Assistant's console shows a hint | No consent state at all, unless you set Consent Mode defaults yourself: Google tags then run as if consent were granted, also in the EU, the UK and Switzerland |
| Pro and higher, switch off, banner loaded by the template | Defaults at once (the switch is not known yet), then nothing | Your defaults for good |
On Free the defaults are deliberate: Google tags never run in an opt-in region without a consent
state. To run tags after the visitor agrees on Free, fire them on the consentl_update or
consentl_consent event with a condition on consentl.analytics or consentl.marketing, or
upgrade to Pro.
With the switch off and the snippet first, the template respects your choice and sends no
Consent Mode command at all. Google tags in your container then run without any consent state
unless you set the defaults yourself (your own gtag('consent', 'default', …) before GTM, or
another tool), and Google treats a missing state as granted. If you rely on this template for
Consent Mode, leave the switch on.
While the plan information is being rolled out to every banner, a Pro site with the switch off can still be handled like Free (defaults, no updates).
Returning visitors and "Reset all consents"
The template does not read the consentl cookie itself. It takes the visitor's choice from the
banner, which has already checked the consent revision ("Reset all consents" asks everyone again),
the expiry, implied choices from notice or opt-out regions (they do not count in opt-in regions) and
Global Privacy Control. Nothing is granted before the visitor's current choice is known. "Wait for
update" (500 ms by default) makes Google tags wait for the banner.
Avoid double defaults
- With the snippet in the page, add
&gcm=extto its URL. - Do not also add
gtag('consent', 'default', …)to the page. - The banner applies your rule for the visitor's country, which Consentl looks up from the IP address
(in memory, nothing stored); Google applies the template rows by its own geolocation. Make the rows
match your rules: denied where a rule is opt-in, and the empty-region row like your rule for all
other regions. The banner does not tell US states apart: every US visitor gets your rule for the
whole US or, without one, your first US-state rule, so give the US one row (
US) with the defaults of that rule.
How categories map to Consent Mode
| Consentl | Consent Mode |
|---|---|
| marketing | ad_storage, ad_user_data |
| marketing + sale | ad_personalization |
| analytics | analytics_storage |
| preferences | functionality_storage, personalization_storage |
| always | security_storage = granted |
Permissions shown in GTM
| Permission | Why |
|---|---|
| Accesses consent state | Writes the consent types and wait_for_update |
| Injects scripts | https://api.consentl.com/v1/* (the banner loader) |
| Accesses global variables | Calls Consentl.on, Consentl.get, Consentl.region, Consentl.stored; reads Consentl.version, consentl.c.gcm.plan (your plan) and consentl.c.gcm.on (the Consent Mode switch) |
| Writes to the data layer | ads_data_redaction, url_passthrough |
| Logs to console | Debug mode only |
Data the banner collects
The template itself sends no data. Consentl processes the following for you as the site owner:
- On every page view, requests to
api.consentl.comfor the banner script, its interface (when shown) and the region lookup. Like any web request they carry the visitor's IP address and browser user agent. - With every choice, a consent record as proof of consent: a random consent ID (also kept in the
consentlcookie), the action and choices, the region code when known, the language, the consent revision, the page path, your host name, the Global Privacy Control signal and, during an A/B test, the banner variant. Consentl adds the time, the shortened IP address (IPv4 /24, IPv6 /48) and the user agent. - When the banner is first shown, an anonymous view count.
- Consent records are kept for 425 days (Free, Pro), 730 days (Business) or 1,825 days (Enterprise). See the privacy policy.
Limitations
- When the banner is loaded by GTM, scripts hard-coded in the page run before it. Put the snippet
first in
<head>for strict prior blocking. - The Community Template Gallery listing is not published yet; use the manual import.
- Consentl is not a Google-certified CMP for IAB TCF and does not implement TCF.
Related guides
Stuck? Write to [email protected] — we answer in English on business days.