Kukie.io can load Google Tag Manager (GTM) for you, ensuring that it only fires after consent defaults have been set. This guarantees that every tag in your GTM container respects the visitor's consent choices from the very first event.
WordPress users: Enter your GTM container ID in the WordPress plugin settings to enable automatic GTM integration.
Entering Your GTM Container ID
In the Banner Editor, go to the Integrations tab. Toggle Google Tag Manager to on and enter your GTM container ID in the format GTM-XXXXXXX.
When saved, the banner script will inject the GTM container snippet into the page at the correct point in the consent flow. You do not need to add the GTM snippet manually to your site's HTML - the banner handles it entirely.
Important: If you enable the GTM integration in Kukie.io, remove any manually placed GTM snippets from your site's HTML to avoid loading the container twice.
How GTM Loads Relative to Consent
The loading sequence is carefully orchestrated:
- The Kukie.io banner script loads and defines
window.dataLayer. gtag('consent', 'default', {...})fires with all parameters set todenied.- For returning visitors with stored consent,
gtag('consent', 'update', {...})fires immediately with their saved preferences. - Only then is the GTM container script injected into the page.
This order is critical. If GTM loaded before consent defaults were set, its tags would fire without knowing the consent state, potentially collecting data that the visitor has not consented to.
Consent Model Impact
The timing of GTM injection depends on the consent model:
- Opt-in - GTM is injected only after the visitor makes a consent choice. Until then, no GTM tags fire.
- Opt-out / Notice Only / Hidden - GTM is injected after consent defaults are set and immediately updated to
granted. Tags fire on first page load.
The cookie_consent_update DataLayer Event
Every time a visitor makes or updates their consent choice, the banner script pushes a cookie_consent_update event to window.dataLayer:
window.dataLayer.push({
event: 'cookie_consent_update',
cookie_consent: {
analytics: true,
marketing: false,
functional: true
}
});
This event contains a cookie_consent object with boolean values for each cookie category. You can use this event as a trigger in GTM to fire or block specific tags based on the categories the visitor accepted.
Setting Up Triggers in GTM
To create consent-aware triggers in your GTM workspace:
Example: Fire Google Analytics Only on Analytics Consent
- Go to Triggers → New.
- Choose Custom Event as the trigger type.
- Set the event name to
cookie_consent_update. - Add a condition: cookie_consent.analytics equals true.
- Save and assign this trigger to your GA4 tag.
Alternatively, if you are using Google Consent Mode (recommended), you can skip custom triggers entirely. GCM handles tag behaviour automatically through the consent state - tags that require analytics_storage will only collect data when that parameter is granted.
Tip: We recommend using both GCM v2 and the
cookie_consent_updateevent together. GCM handles Google's own tags automatically, while the dataLayer event lets you control third-party tags (Hotjar, Facebook Pixel, etc.) with custom triggers.
Using GCM v2 with GTM
When both Google Consent Mode v2 and GTM are enabled, they work together seamlessly. GCM tells Google tags how to behave based on consent, while GTM acts as the container that loads and manages those tags. The banner script ensures both are initialised in the correct order.
Troubleshooting
Tags not firing after consent
Check that the GTM container ID is correct (format: GTM-XXXXXXX). Open your browser's developer tools and look for a network request to googletagmanager.com. If you do not see one, the GTM integration may not be enabled or the consent model may be blocking it.
Duplicate GTM containers
If you see GTM loading twice, you likely have both a manual GTM snippet in your site's HTML and the Kukie.io GTM integration enabled. Remove the manual snippet and let Kukie.io manage GTM injection.