Changes to the IAB CMP Framework JS API
Important: If CMP settings are used that are not compliant with the IAB TCF, the system will automatically disable some commands. The standard IAB TCF commands (e.g. getVendorConsents
) will then only be available via prefixed command name (e.g. noncompliant_getVendorConsents
instead of getVendorConsents
). More information on TCF compliance can be found here.
In order to allow more flexibility, we added some extensions to our implementation of the IAB CMP Framework JS API. These are:
Command |
Description |
|
The global |
|
The global |
|
See section CMP Events. |
|
Equal to IAB getVendorConsents but also returns |
|
Equal to IAB getTCData but also returns |
Example:
<script>
var vendorid = 3; //vendor number 3
var purposeid = 1; //allow cookies
var x = __cmp("consentStatus", null, null, false);
if(typeof(x) == 'object' && "consentExists" in x && x.consentExists)
{
//consent data is present, check if consent for vendor is given
var y = __cmp("getVendorConsents", new Array(vendorid), null, false);
if(typeof(y) == 'object' && "gdprApplies" in y && (!y.gdprApplies || (y.vendorConsents[vendorid] && y.purposeConsents[purposeid])))
{
//everything is fine!
}
}
</script>
(Please make sure to remove incorrect line breaks when coping the text above)
The example above shows a sample code on how you can check if the consent string is present and if consent is given for a certain vendor & purpose in a synchronous way.