Consent Events
Listen to the Consent Engine
The JENTIS Consent Engine will differentiate several situations. You can react to those events by using the following listener callback functions.
Synchronous (Generic) Listener
You can listen to the JENTIS Consent Engine events by the following window native event, if you are sure that your listener call is executed before the main JENTIS JS snippet is executed.
JavaScript
document.addEventListener('<eventname>', function (e) {
console.log(e.detail.<more info>);
});
The elements which are written within <…> are dynamic data which are defined in the following table.
Asynchronous (Specific) Listener
Sometimes an application can not guarantee to be executed before the JENTIS JS snippet is executed. For example if you are using an external Tag Management System like Google Tag Manager. In this case you can use the following code to listen to a JENTIS Consent Engine event (defined in the eventname property).
JavaScript
jentis.consent.engine.addEventListener('<eventname>',function(e) {
console.log(e.detail.<more info>);
});
The advantage of this usage of the internal Event Listener is, if you missed the event, the JENTIS Consent Engine object will find this missed event and will call the callback function immediately.
Best Practice to Writing a Listener
JavaScript
if(typeof window.jentis !== "undefined" && typeof window.jentis.consent !== "undefined" &&typeof window.jentis.consent.engine !== "undefined")
{
//If the engine is allready loaded, we maybe missed the events, so we want to register at the engine instead of the document.
var oEventBaseObject = window.jentis.consent.engine;
}
else
{
//No engine allready exists, so it is safe to register at the document.
var oEventBaseObject = document;
}
//Now listen to the Init Event of the Consent Engine.
(function(oMe,oEventBaseObject){
oEventBaseObject.addEventListener('jentis.consent.engine.init',function(e)
{
oMe.consentEngineReady = true;
oMe.startTracking();
});
})(this,oEventBaseObject);
List of JENTIS-Consent-Engine Events
jentis.consent.engine.show-bar
This event means you should show the consentbar to the user so the user can make his descissions.
jentis.consent.engine.user-show-settings
This event means you should show the setting page regarding to vendors and consent because the user requestet it by himself.
jentis.consent.engine.vendor-change
At least one of the vendors consents had changed.
At e.moreInfo you will find an additional Object with all vendors and consent information
Markup
<code style="box-sizing: border-box; font-family: var(--bs-font-monospace); font-size: inherit; direction: ltr; unicode-bidi: bidi-override; color: inherit; overflow-wrap: break-word; word-break: normal; display: block; white-space: pre-wrap;">{ "ga" : true, "adw" : false, "fb" : true }</code>
jentis.consent.engine.vendor-add
At least one more positive consent was given.
At e.moreInfo you will find an additional Array with all vendors which have currently a positive consent
JavaScript
["googleanalytics", "fb"]
jentis.consent.engine.init
The JENTIS-Consent-Enginge is fully loaded and ready to work
jentis.consent.engine.minimal-consent-given
A minimal consent is given, means at least one vendor has a positive consent. This event triggers if the consent is given because the user is giving the consent right now through the consentbar or the consent was given by the user at a previous page.
jentis.consent.engine.no-consent-given
No consent is given, means at no vendor has a positive consent. This event triggers if the consent is given because the user is denying the consent right now through the consentbar or the consent was denied by the user at a previous page.
jentis.consent.engine.send-consent-data
Consent Data must be send to the server. Triggers every time if the engine wants to store the data persistently at the server.
At e.moreInfo you will find an additional Object with the Consent Data.
{
"consentid" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"lastupdate" : 36473882736,
"vendors" : {
"ga" : true,
"adw" : false,
"fb" : true
},
"vendorsChanged": {
"ga" : true
}
}