Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

Functionality

The function getCustomVendorsConsent is used to retrieve consent for a list of custom vendors defined with setCustomVendors.

In order to retrieve consent for a list of custom vendors defined by the publisher (please check the setCustomVendors configuration function), the function getCustomVendorsConsent must be used. AdConsent will then return a structure holding a set of key-value pairs where the key is the vendor ID and the value is a boolean stating whether or not that vendor has consent. This feature applies to GDPR only.

Syntax

function adconsent.gdpr()

argument name

type

optional

value

description

command

string

'getCustomVendorsConsent'

parameter

array of int

e.g. null, [3], [1, 2]

Array with the list of custom vendor ids to fetch the consent for or null to obtain the consent value for all custom vendors.

callback

function

function(consents:ConsentStructure, success:boolean)

The callback function that is called with the function call result.

ConsentStructure

The ConsentStructure object holds the consent values for the defined list of custom vendors.

Code Block
ConsentStructure = {
  "vendor1ID": true | false,
  "vendor2ID": true | false,
  ...
  "vendorNID": true | false
}

Description

When working with GDPR users, a publisher may need to get consent for other vendors other than the IAB compliant ones, e.g. when using some special analytics tool or other product from a company that is not registered in the IAB Global Vendor List. The function setCustomVendors is used to configure AdConsent with an additional list of custom vendors to get consent for them.

After AdConsent gets consent from the user, either by a new submission or through a previously stored consent string, the function getCustomVendorsConsent can then be called to check consent for these vendors and act accordingly.

The callback will only be called after AdConsent reads or gets consent from the user and the user is in the GDPR region. Outside of GDPR, the callback will not be called.

Scope

This function can be called at any time in AdConsent execution timeline.

Examples

Check consent given for custom vendor with id 5

This example assumes that the user is in the GDPR consent region.

Code Block
adconsent.gdpr('getCustomVendorsConsent', [5], function(consent) {
  if (consent['5']) {
    console.log("consent for custom vendor 5, do whatever needed - ie. code to run vendor tags");
  } else {
    console.log("no consent for custom vendor 5");
  }
});

Same example as above, but with a full integration with the different possibilities of consent zones

This example works worldwide, taking all consent regions into consideration.

Code Block
__tcfapi('addEventListener', 2, function(tcData, success) {
  if(success && (tcData.eventStatus === 'tcloaded' || tcData.eventStatus === 'useractioncomplete')) {
    // check if GDPR applies
    if(tcData.gdprApplies) {
      adconsent.gdpr('getCustomVendorsConsent', null, function(consent) {
        if(consent['5']) {
          console.log("gdpr: consent for custom vendor 5, do whatever needed - ie. code to run vendor tags");
        } else {
          console.log("gdpr: no consent for custom vendor 5");
        }
      });
    } else {
      __uspapi("getUSPData", 1, function(uspData, success) {
        if(success) {
          // check if CCPA applies
          if(uspData.uspString == "1---") {
            console.log("full consent as neither gdpr nor ccpa applies");
          } else if(uspData.uspString.toUpperCase().charAt(2) == 'Y') {
            console.log("ccpa: user has opted out");
          } else {
            console.log("ccpa: full consent");
          }
        }
      });
    }
  }
});