__tcfapi function - ping call

The ping command will return the IAB TCF v2 ping object that you can use to determine whether the main CMP script has loaded and if GDPR applies for your pageview.

  Note: Click here to find more information about the TCF API commands from the IAB.


Command

Your organization can call the ping command through the browser console or Javascript code on a webpage.

Browser console JavaScript

Once your organization's website has loaded, enter the following command directly into the browser tools' console window.

__tcfapi('ping', 2, (pingReturn) => {
   console.log("retrieving pingReturn: ", pingReturn)
});

Response

Model Example

The ping response is an object that contains the data described below:

Parameter Type Description
cmpId Number IAB Assigned CMP ID
cmpStatus String This property has the following values:
  • loaded if the CMP has finished loading
  • stub if the CMP not yet loaded – stub still in place
  • error if the CMP is in an error state. A CMP shall not respond to any other API requests if this cmpStatus is present.
A CMP may set an error if it is unable to perform the operations in compliance with the TCF
cmpVersion Number CMPs own/internal version that is currently running
gvlVersion Number Version of the Global Vendor List currently loaded by the CMP
gdprApplies Boolean the CMP sets the value:
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.
tcfPolicyVersion Number CMPs own/internal version that is currently running
cmpLoaded Boolean indicates if the CMP main script has loaded:
true CMP main script is ready
false CMP main script has not loaded, stub still running
displayStatus String visible | hidden | disabled
apiVersion String version of the CMP API that is supported. Currently the value is "2.0"
Was this article helpful?
0 out of 0 found this helpful