Google Tag Manager
Last updated: September 8, 2026
Cookiestack doesn't replace or load your GTM container for you — you install your own GTM snippet as usual. The widget's job is to set the consent state before tags inside the container get a chance to fire, and to update it as soon as the visitor makes a choice. This works through Google Consent Mode v2 — see the dedicated Google Consent Mode v2 guide for the technical details.
Tag order matters
The Cookiestack script must sit in <head> before your GTM snippet:
<script
src="https://api.cookiestack.dev/widget.js"
data-api-key="YOUR_API_KEY"
async
></script>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){ ... })(window,document,'script','dataLayer','GTM-XXXXXXX');</script>Reverse the order and some GTM tags can fire before the widget sets a default consent state — Google no longer counts that as a valid Consent Mode setup.
Enable the integration
Under the domain's Integrations tab, enable Google Consent Mode v2 — the "Container ID" field there is for reference, to tie the integration to the right GTM account. From then on the widget calls gtag('consent', 'default', …) on page load and gtag('consent', 'update', …) on every visitor decision — you don't need to call gtag yourself.