Cookie Consent Events

You can include the following functions in your website code when you implement Privacy Pillar's cookie banner on your website.

Initialization

The function given below calls once the cookie banner application is initialized on your website. 

window.addEventListener('OnConsentInit', (e) => console.log(e.detail));

When the user clicks Privacy Settings on the cookie notice or clicks the consent badge on the window, the preference pop-up opens by calling the below functions

If you are using version 1, then use the below function

window.AzCMP.onOpenPopUp();

If you are using Version2, then use the below function

window.AZCookieConsent.onOpenPreference();

When the user provides any consent using the cookie banner, the event will return a value, and the same can be viewed by calling the below function.

window.addEventListener('OnConsentInit', (e) => console.log(e.detail));

An example is given below:

The detailed information of the consent provided by the user like the consent status, and the purposes opted in and opted out can be viewed by calling the below function.

window.AZCookieConsent.onGetConsentDetails();

An example console is given below:

It returns the status of the consent given by the user.

window.addEventListener('AzConsentStatus', e => { console.log(e.detail) })

An example status is given below: