Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. The Usercentrics CMP template tag registers default consent settings, so the consent mode script doesn’t need to be used with that implementation method for the Usercentrics CMP, as long as all relevant Google tags are handled in the Google Tag Manager. (No default consent needed on the page.)

  2. If you don’t implement Usercentrics CMP via the template tag in Google Tag Manager, you’ll need to add a script to your page to enable it.

Let’s have a look at that script for option 2:

Code Block
<script type="text/javascript">
// create dataLayer
    window.dataLayer = window.dataLayer || [];
    
//Create the gtag API, so you don’t have to write dataLayer.push() and can use gtag() instead.   
    function gtag() {
        dataLayer.push(arguments); 
    }

//Use the gtag method to pass default consent settings to Google Tag Manager.
    gtag("consent", "default", {
        ad_user_data: "denied",
        ad_personalization: "denied",
        ad_storage: "denied",
        analytics_storage: "denied",
        wait_for_update: 2000 // milliseconds to wait for update
    });

// Enable ads data redaction by default [optional]
    gtag("set", "ads_data_redaction", true);
</script>

//The last part is the Google Tag Manager script. If you want to use Consent Mode as alternative to prior blocking the type of the script tag is "text/javascript".
<script type="text/javascript">
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window, document, 'script', 'dataLayer', 'GTM-XXXXX'); //replace GTM-XXXXXX with Google Tag Manager ID
</script>

...