Info
Content

Working with Google Consent Mode v2 + Manual/Semiautomatic Blocking Code

Note: This page describes the use case when you are using Manual/Semiautomatic Blocking Code and Google Analytics or Google Ads Tracking directly in the website (no GTM is used). For GTM use cases please see here.

If you are using the Manual Blocking Code in your website and want to achieve the "Basic Implementation" (also known as "hard blocking"). The advantage here is a higher legal safety. The downside is a less accurate tracking (for users that did not give consent).

You will not need to do any additional changes. Please keep sure that you have the Manual Blocking Code correctly implemented:

  • Ensure the Manual Blocking Code is placed as soon as possible in the page, preferably before any Google Code
  • Ensure Google Analytics, Google Ads or the other Google services are in your vendorlist
  • Ensure Google Analytics, Google Ads or other Google Codes are blocked by adjusting the Google Code. See examples for manually blocking Google Analytics .
  • The following Code should be inserted before the first Google Code:
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}

  gtag('consent', 'default', {
    'ad_storage': 'denied',
    'analytics_storage': 'denied',
    'ad_user_data':'denied',
    'ad_personalization': 'denied',
    'wait_for_update': 500
  });

  dataLayer.push({
    'event': 'default_consent'
  });
</script>

The code example above, sets the default status for ad_storageanalytics_storagead_user_data and ad_personalization to denied. Please note that there are other status that you can set in order to fine-tune the behavior.

The Advanced Implementation is the way in which the Google Analytics Tags or Google Ads Tags are fired even if no consent is given. In this case the Consent Mode signals are used to tell Google Analytics or Google Ads to limit the tracking. This is usually also called "soft blocking". The advantage here is a higher accuracy in tracking. The downside is a lower legal safety.

In order to implement the Advanced Implementation of either Google Analytics or Google Ads when Manual Blocking Code is used please follow these steps:

  • Ensure the Manual Blocking Code is placed as soon as possible in the page, preferably before any Google Code
  • Ensure Google Analytics, Google Ads or the other Google services are in your vendorlist
  • Do NOT manually block Google Analytics, Google ads or other Google Codes (do not change the Google Codes)
  • The following Code MUST be inserted before the first Google Code:
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}

  gtag('consent', 'default', {
    'ad_storage': 'denied',
    'analytics_storage': 'denied',
    'ad_user_data':'denied',
    'ad_personalization': 'denied',
    'wait_for_update': 500
  });

  dataLayer.push({
    'event': 'default_consent'
  });
</script>
Back to top