Consent Events
  • 14 Jun 2022
  • 2 Minutes to read
  • Contributors
  • Dark
    Light

Consent Events

  • Dark
    Light

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.


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).


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


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);

This event means you should show the consentbar to the user so the user can make his descissions.

This event means you should show the setting page regarding to vendors and consent because the user requestet it by himself.

At least one of the vendors consents had changed.

At e.moreInfo you will find an additional Object with all vendors and consent information


<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>

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


[ "ga", "fb" ] 

The JENTIS-Consent-Enginge is fully loaded and ready to work

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.

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.

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
  }
}


Was this article helpful?

What's Next