QR CMP: Events

QR CMP: Events

IAB predefined events

Once the CMP has been loaded, the __tcfapi method is created, which is used to retrieve the consent string, get consent for a specific purpose, etc. The full definition and all available standard API commands can be found at the following link.

The CMP launches a series of events predefined by the IAB to detect the following:
  1. CMP and consent tring loaded (event 'tcloaded')
  2. CMP is shown (event 'cmpuishown')
  3. Consent string saved (event 'useractioncomplete')
These events are caught by the __tcfapi method with the 'addEventListener' command.

Example:
The CMP is running on a TV device, ES6 javascript cannot be used: functions arrow, const, let, etc. ES5 must be used. 
  1. var tcLoadedCallback = function(tcData, success) {                                                                                                        
  2.  
  3.   if(success && tcData.eventStatus == 'tcloaded') {

  4.     // do something with tcData.tcString

  5.     __tcfapi('removeEventListener', 2, function(success) {

  6.       if(success) {
  7.         // listener removed
  8.       }

  9.     }, tcData.listenerId);

  10.   } else {
  11.     // do something else
  12.   }

  13. }

  14. __tcfapi('addEventListener', 2, tcLoadedCallback);

Sibbo custom events

The CMP launches a series of custom events to detect the following:
  1.  The CMP has finished the initialization ('sibbo-init' event)
  2. The CMP has been closed ('sibbo-close' event)
Examples:
The CMP is running on a TV device, ES6 javascript cannot be used: functions arrow, const, let, etc. ES5 must be used. 

  1. function sibboInitCallback()  {
  2.   // the CMP has  finished the initialization 
  3.   // do something else
  4. }

  5. document.addEventListener('sibbo-init', sibboInitCallback);

  1. function sibboCloseCallback()  {
  2.   // el CMP has been closed
  3.   // do something else
  4. }

  5. document.addEventListener('sibbo-close', sibboCloseCallback);