__tcfapi()
function. Your organization can use these commands in Javascript source code to perform actions specific to your needs. Click here to find more information about the TCFv2 API commands from the IAB.__tcfapi()
arguments__tcfapi()
function takes up to four arguments:'2'
success
and using the data in tcData
. See below for more information.tcData
that operate under legitimate interest.tcData
- a JSON object that contains both the encoded and unencoded values of the TC stringsuccess
- a boolean value (true
/false
) that informs if the command request was successful__tcfapi()
commands__tcfapi()
function provides four commands: getTCData
, ping
, addEventListener
, removeEventListener
getTCData
commandgetTCData
command allows your organization to retrieve unencoded and encoded values of the TC String. The TC String also provides additional information about the CMP event status, if GDPR applies to the end-user and more.getTCData
command can be called in the browser console. For more information, please follow the links below:gdprApplies
true
if GDPR applies
• false
if GDPR does not apply
If your organization decides that GDPR applies to all traffic they can signal the CMP to always return true
. eventStatus
tcloaded
- if the CMP has a valid TC String to deliver to any calling scriptscmpuishown
- when the first layer message is shown to the end-useruseractioncomplete
- when the end-user has confirmed their choices and the CMP has the corresponding TC String to send to any calling scriptscmpStatus
stub
- the CMP has not yet loadedloaded
- the CMP has loadederror
- the CMP has an error and is unable to repond to any API requests. A CMP may set this if, for any reason, it cannot perform an operation that complies with the TCFlistenerId
getTCData
command has been called in response from an addEventListener
actionconsents
true
- consent grantedfalse
- no consent givenlegitimateInterests
true
- legitimate interest establishedfalse
- no legitimate interest establishedconsents
true
- consent grantedfalse
- no consent givenlegitimateInterests
true
- legitimate interest establishedfalse
- no legitimate interest established purpose id
vendor id
0
- not allowed1
- require consent2
- require legitimate interestping
commandping
command informs whether or not the main CMP script has loaded and if GDPR applies. This command should be implemented and called before any other command.apiVersion
cmpLoaded
true
- CMP main script is readyfalse
- CMP main script has not loaded, stub still runninggdprApplies
true
if GDPR applies
• false
if GDPR does not apply
If your organization decides that GDPR applies to all traffic they can signal the CMP to always return true
. addEventListener
commandaddEventListener
command. The addEventListener
command registers a callback function with the CMP. removeEventListener
. The callback function can optionally be triggered for three specific event status.tcloaded
cmpuishown
useractioncomplete
removeEventListener
command__tcfapi()
function using the removeEventListener
command.tcData.listenerId
. This id is automatically created with the addEventListener
command.