/consentmode

explanation for the consent mode implementation by Google

Primary LanguageHTML

Consent Mode

This repo aims to be an easy and understandable guide to the implementation of the Consent Mode by Google if you are using your own cookie banner. There are three files:

  1. consent.html is an HTML page that shows the logic behind the consent mode and can be used to test your own implementation
  2. GTM_consentMode.json it is a Google Tag Manager container that can be imported in your GTM account
  3. consentMode.md shows two ways to implement this feature if you are using your own cookie banner

The logic behind the Consent Mode itself it is quite easy:

  • The command gtag('consent', 'default' is called before any Google tag and before the cookie banner. At this stage the Analytics/Ads or GTM tag has to be loaded as well. No cookies will be saved on visitor's machine
  • The cookied banner loads and waits for the user's choice
  • The selection on the cookie banner calls the command gtag('consent', 'update' which should update the tags accordingly to the user's preferencs

I am using two ways to implement the Consent Mode without using CMPs as Iubenda, Cookiebot etc. Ideally, you wanna use one of these if you want to create your own cookie banner or if you are using a generic cookie banner.

Additional links from Google: