-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Summary
When using DynamicWeb’s Cookie Manager, the function
gtag('consent', 'update', ...) is triggered whenever cookies are allowed.
However, this command does not automatically push an event to the GTM Data Layer, meaning Google Tag Manager (GTM) has no native trigger to detect when consent has been updated.
Problem
When implementing non-Google tags (e.g. third-party pixels), it’s important to have a way to trigger them immediately after consent is granted.
Since the gtag('consent', ...) command only updates Google’s internal consent state — and does not act as a general GTM event — these third-party tags currently have no way to listen for consent updates.
Proposed Solution
Add a custom Data Layer event that fires immediately after consent is updated.
This would enable GTM to trigger non-Google tags (such as marketing or tracking pixels) as soon as consent is given.
Example Implementation
// 1. Update the Google Consent Mode state
gtag("consent", "update", {
ad_storage: "granted",
ad_user_data: "granted",
ad_personalization: "granted",
analytics_storage: "granted"
});
// 2. Immediately push a custom event to the GTM Data Layer
dataLayer.push({
event: "consent_updated" // <-- GTM can listen for this custom event
});
Benefits
- Allows non-Google tags to respect user consent while still loading immediately after it’s granted.
- Keeps consent management fully aligned with GTM best practices.
- Provides a simple, transparent mechanism for developers to integrate with existing GTM setups.