Read TC string using GDPR TCF API

The Consent Management Platform (CMP) API provides your organization and third-party vendors access to user consent preferences managed by the CMP.


The __tcfapi() function

The __tcfapi() function allows your organization, advertisers and third party vendors to read the consent data. It can be called in JavaScript code (see here) but this article describes how it can used in a browser console window.

  Note: Open the Sourcepoint website to display a consent message and open the console in the browser developer tools. Click the provided button to give full consent and in the console type this command:

__tcfapi('getTCData', 2, function(tcdata,success){console.log("GET TCDATA:", tcdata);});

The console window will return the response from the TCF API command as shown below. The categories for publisher, purpose, tcString and vendor provide full consent information granted by the user.

Browser console window

console_results.jpg

Expand the API response. In the table below, we have provide descriptions for some key categories in the response:

Category description

Category Description
publisher If your organization acts in a data processing capacity. If a user has given you consent or accepts your legitimate interest to process data for IAB or custom purposes. Also if your organization has restrictions on certain vendors to process data for a purpose.
purpose Which purpose the user grants vendors consent or accepts legitimate interest for data processing.
tcString An encoded string containing all the information from the __tcfapi response.

The value can be copied and decoded using a service provided by the IAB here.
purpose Which vendor has consent or approved legitimate interest to process user data.

Each category has sub-categories for consent (consents), legitimate interests (legitimateInterests) and restrictions (restrictions, for publishers only).

Was this article helpful?
0 out of 0 found this helpful