Just like vendors, some publishers will need to wait for a consent signal before setting cookies or processing user personal data for one or more of the purposes they selected—if they choose consent as their legal basis for one or more of the purposes.
In order to retrieve consent, publishers need to update their website code to look for the consent signal. This can be done through the IAB TCFv2 API __tcfapi using the ‘getTCData’ command provided by the Choice CMP. The publisher will need to check for consent given for the desired purposes listed in the purpose field (tcData.purposes.consents). A publisher can claim purpose(s) under legitimate interest. If that is the case the publisher will need to check whether a user opted out of the purpose (tcData.purposes.legitimateInterests). More info can be found in the IAB Europe Transparency and Consent Framework JS API Specification.
Executing Code after Consent Collection
In order to perform an operation when the user has made a new choice of consents (the tcString has changed), use the following “__tcfapi” operation to register a callback:
__tcfapi('addEventListener', 2, callback)
The callback will be invoked with the TCData object as an argument whenever the TC string is changed and a new one is available. The TCData object will contain a CMP-assigned listenerId for the registered listener.
To remove the event listener you call call the __tcfapi using this command:
__tcfapi('removeEventListener', 2, callback, listenerId)
For more information please refer to the IAB Europe Transparency and Consent Framework JS API Specification.