Consent Mode is a feature by Google that allows websites to adjust how they track users based on their consent choices regarding cookies, advertising, analytics, and other categories of data processing.
Stape created a Consent Parser variable that reads the encoded Consent Mode v2 string from the ‘gcd’ standard parameter of GA4 hit, decodes it, and returns the consent states for various categories (e.g., ad_storage, analytics_storage) in a readable format. This helps determine what data can be collected and processed based on user preferences.
This variable is useful for websites using Consent Mode to manage user privacy preferences, especially in the context of privacy laws like GDPR and CCPA. By decoding the consent string, server-side tags can selectively fire or avoid firing based on the user's consent, ensuring compliance with legal requirements.
2. Download the Consent Parser variable from GitHub.
3. Import the variable to server Google Tag Manager by clicking Templates → New Variable Template → Click three dots in the top right corner → Click import → Add template that you’ve recently downloaded → Click Save.
4. Go to Variables → New → Choose ‘Consent Parser’ → Click Save.
The variable works based on the ‘gcd’ parameter that collects GA4 automatically if your consent banner works with Google Consent Mode support.
The variable itself will find ‘gcd’ in the incoming hit and decode all the details in it into separate categories.
In the variable Analytics Debugger OpenAPI is used to decode the consent string.
This is a handy tool for parameter debugging that you can use online:
Here are three benefits of using the Consent Parser variable in server-side Google Tag Manager:
And if you’d like to read more about Consent Mode, here you can find some useful articles:
Stape has lots of tags for server GTM! Click on Try for free to register and check them all.