Advanced

Callbacks

It is possible to define different callbacks to execute actions once the customer has made their selection.

CookiebotCallback_OnLoad

The asynchronous callback is triggered when the cookie banner has been loaded to obtain the user's consent.

You want e.g. B. load the Google Tag Manager as soon as the Consent Manager is loaded? To do this, please insert the following code into the field:

function CookiebotCallback_OnLoad()
{
    var googleTag = 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);};
        googleTag(window, document, 'script', 'dataLayer', gtmContainerId);
        googleTag = null;
}

The preceding code assumes that you have already implemented the Tag Manager.

CookiebotCallback_OnAccept

An asynchronous callback is triggered when the user clicks the confirmation button of the cookie consent dialog and when a user who has consented loads a page.

You want e.g. B. only activate the wish list once the customer has accepted the necessary cookies.

function CookiebotCallback_OnAccept()
{
    if (Cookiebot.consent.preferences){
        document.cookie = 'wishlist-enabled=1;path=/'
    } else {
        document.cookie = 'wishlist-enabled=;path=/'
    };
}

For more information about the properties, see https://www.cookiebot.com/de/developer/#h-eigenschaften

CookiebotCallback_OnDecline

The asynchronous callback is triggered when the user declines the use of cookies by clicking the decline button in the cookie consent dialog. The callback is also triggered when a user who has opted out of cookies loads a page.

CookiebotCallback_OnDialogInit

Fired when the cookie consent banner is initialized before the content of the banner is compiled.

CookiebotCallback_OnDialogDisplay

Fired when the cookie consent banner is shown to the end user.

CookiebotCallback_OnTagsExecuted

Fires when tags marked for prior consent (e.g. the “data-cookieconsent” attribute) fire.

You can find more information about event handling at https://www.cookiebot.com/de/developer/#h-Event Treatment and about callbacks at https://www.cookiebot.com/de/developer/#h-ruckrufe

Always allow Google Tag Manager

The Cookiebot script is loaded after the tag manager script. This ensures that the tag manager runs even if the Cookiebot blocking mode is set to auto.

Last updated