Google Consent Mode Listener tag
When a user updates their consent preferences through a cookie banner, the Consent Management Platform (CMP) typically updates the consent state used by Google Consent Mode. However, not all CMPs push a dedicated dataLayer when these changes happen.
Without a consent update event, GTM may not have a reliable trigger for tags, scripts, or custom workflows. This can make it difficult to trigger non-Google tags, handle consent preference changes, or build consent-dependent tracking logic.
This guide explains how to use the Google Consent Mode Listener tag developed by Stape to create a consent update event in the dataLayer whenever monitored consent types change. You'll also learn how to configure GTM to use this event as a trigger and verify that consent updates are working correctly.
How to configure the Google Consent Mode Listener tag
1. Download the tag file from Stape's GitHub and unzip it.
Currently, the tag isn't available in the GTM Template Gallery, so the setup requires adding it manually to the GTM workspace.

2. Upload the tag template into the web GTM container workspace.
Go to the Templates section → in the Tag Templates, click New → click on the three dots in the upper-right corner → click Import → select the file from your desktop → click Save.

3. Create a new tag.
Go to the Tags section → click New → Tag Configuration, select Google Consent Listener Tag by Stape.

4. Configure the tag.
- Consent Types to Monitor – choose whether to listen to all consent types or only specific ones.Whenever one or more monitored consent types change, the tag pushes one event containing a consent object with the current state of all monitored types:
{
event: 'stape_consent_update',
consent: {
ad_storage: 'granted',
ad_user_data: 'granted',
ad_personalization: 'denied',
analytics_storage: 'granted',
functionality_storage: 'denied',
personalization_storage: 'denied',
security_storage: 'granted'
}
}For our case, we select the All Consent Types option.
- (Optional) Configure using a custom event name or dataLayer name.
You can add some custom configuration if you check the checkboxes next to Use custom event name and/or Use custom dataLayer name.
If these boxes aren't checked, the default Stape event named stape_consent_update will be pushed.
With the Use custom event name option, the standard event will be overridden to one you specify.
Use custom dataLayer name option allows you to use a custom dataLayer name.
Warning:
If you use a custom named dataLayer, you will need to add a global variable permission (read/write) within the template. Be aware that by doing so, your template will unlink from the Community Gallery (unlinking it from the Gallery results in not receiving any future updates for this template).
For the purpose of our setup, we won't check any of the boxes.

5. Add a trigger for a tag.
This Listener tag must fire after your CMP has established the default consent baseline. If the Listener initializes before your CMP sets a default consent state, the Listener may capture incorrect initial consent values, resulting in inaccurate reporting of subsequent consent changes.
So if your CMP tag sets the default state using the Consent Initialization - All Pages trigger, you should fire this Consent Listener tag on the Initialization - All Pages trigger.

Alternatively, use GTM's tag sequencing feature to guarantee the Listener tag fires immediately after your CMP tag completes its execution.

6. Create a Custom Event trigger matching your event name.
To do it, in your GTM web container, go to Triggers → click New → select the Custom Event trigger type.
Enter the event name that the Google Consent Mode Listener tag pushes to the dataLayer. By default, this is stape_consent_update.
Save the trigger.

7. Update the triggers with the trigger groups.
To fire a tag only after consent has been updated, you may need to check two conditions:
- The user has triggered the corresponding event;
- The consent update event has been triggered containing the required consent status for data collection.
You can use a Trigger Group to combine these conditions and fire the tag only when both conditions have been met.
Depending on your setup, GTM's built-in consent checks may already be enough. Trigger Groups are most useful when a tag must fire specifically after a consent-change event.

Test tag configuration
1. Run Preview in GTM.
Interact with the cookie banner and trigger events on your website.
2. Check the debug window and ensure that:
- Confirm that your CMP establishes the initial consent state before the Google Consent Mode Listener tag starts monitoring consent changes.
- After changing consent preferences, confirm that the
stape_consent_updateevent appears and that the Consent tab shows the updated consent statuses. - Navigate to the Consent tab and ensure that statuses correspond to the ones you've specified via the banner. In most Consent Mode implementations, consent defaults are configured as Denied until the user makes a choice.

Was this article helpful?
🍽 Table of content:
Comments