CMP API
Overview of CMPs and TC String
Consent Management Platforms (CMPs) play a pivotal role in ensuring transparency, obtaining user consent, registering objections, and capturing user preferences through Signals. These Signals are encapsulated within a standardized, easily communicable payload known as a TC String. The CMP API serves as the standardized gateway, allowing various entities, such as hosting publishers and advertising vendors, to access and utilize the user preferences effectively managed by the CMP.
Accessing User Preferences with the CMP API
The CMP API streamlines the process of obtaining the TC String payload and its associated information. This payload is readily accessible and usable, sparing the need to decipher its format. Consequently, scripts and organizations can promptly make data processing decisions based on the retrieved information, without the necessity to understand the intricate details of unpacking the payload format.
Proprietary Interfaces in CMPs
CMPs may also offer proprietary interfaces tailored to specific functionalities or capabilities. These proprietary interfaces are comprehensively documented in the IAB Europe Transparency and Consent Framework Policies, ensuring clarity regarding their design and operation.
CookieHub & CMP API Integration
CookieHub facilitates interaction with the CMP API by exposing the standard __tcfapi function in accordance with IAB's specifications. This function serves as a crucial tool for vendors seeking to access the user's consent state.
CMP API Stub
To ensure seamless integration with tcfapi, the CMP API Stub must be loaded synchronously before any other scripts relying on tcfapi. The stub provides a basic implementation of __tcfapi temporarily until the full implementation is loaded. You can access the CookieHub CMP Stub at the following URL:
Sample Code for Interaction
Here's an example of using __tcfapi for common interactions:
Ping
The "ping" command triggers the callback immediately without involving asynchronous logic. It returns a PingReturn object that helps determine whether the main CMP script has loaded and whether GDPR regulations are applicable.
__tcfapi('ping', 2, (pingReturn) => {
// Handle pingReturn data
});
getTCData
The "getTCData" command retrieves the complete, unencoded TC String, including the current consent state and information about the CMP.
__tcfapi('getTCData', 2, (tcData, success) => {
if (success) {
// Handle tcData
} else {
// Handle other scenarios
}
}, [1, 2, 3]);
For more details on the exposed commands and a comprehensive list of available commands, refer to the Consent Management Platform API specification.