PubConsent
Web Standard Integration

Gtag Integration (Consent Mode)

4min
the following guide shows how to send the update consent signal to gtag through the mapping offered by pubconsent this documentation is intended to provide a detailed overview of each setting in google’s consent mode, strictly following the explanations and guidelines as provided by google it does not imply that the consent mode settings are designed to satisfy or address any particular regulatory requirements the complete explanation of how google's consent mode works is available at the following link https //support google com/google ads/answer/10000067 https //support google com/google ads/answer/10000067 before following this guide, make sure that the pubconsent integration code available in the configurator is present on the page make sure you have followed the steps provided by the google documentation at the following link https //developers google com/tag platform/security/guides/consent?consentmode=advanced https //developers google com/tag platform/security/guides/consent?consentmode=advanced add the following script to set the default consent status, before the cmp script integration code \<script> gtag('consent', 'default', { 'ad storage' 'denied', 'ad user data' 'denied', 'ad personalization' 'denied', 'analytics storage' 'denied' }); // other calls to the gtag method must be placed after the call with consent default \</script> the call shown must be the first call to the gtag method, even before the call gtag('config', \<code>) after configuring the default state of the consent mode, you need to configure the callback that will allow you to execute the update with the values of the consent mode taken from the user's consent \<script> var pubtech queue on consent = pubtech queue on consent || \[]; pubtech queue on consent push( function onconsent( cmptype, data ) { if (cmptype == 'tcf v2 gdpr') { var googleconsents = data integrations googleconsentmode; gtag("consent", "update", { ad user data googleconsents aduserdatagranted ? "granted" "denied", ad personalization googleconsents adpersonalizationgranted ? "granted" "denied", ad storage googleconsents adconsentgranted ? "granted" "denied", analytics storage googleconsents adconsentgranted ? "granted" "denied", }); } if (cmptype == 'google consent mode') { var googleconsents = data integrations googleconsentmode; gtag("consent", "update", { ad user data googleconsents aduserdatagranted ? "granted" "denied", ad personalization googleconsents adpersonalizationgranted ? "granted" "denied", ad storage googleconsents adconsentgranted ? "granted" "denied", analytics storage googleconsents adconsentgranted ? "granted" "denied", }); } }, ); \</script> consents' mapping (google consent mode) to know which user choices correspond to google's consent types, here's the corresponding mapping we provide ad storage > tcf purpose 1 ad user data > tcf purpose 1 e 7 ad personalization > tcf purpose 3 e 4 analytics storage > cookie measurement functionality storage > cookie feature personalization storage > cookie user experience security storage > cookie feature the consent mapping is 1 to 1, meaning that in the consent panel you will see the types of consent from google consent mode listed without any mask