Generate IAB TCF consent string
To generate an IAB TCF consent string, you must implement the IAB Europe Transparency and Consent Framework policies in your CMP UI and features.
If you are collecting consents from users in the European Union, the Didomi Consents API can generate an IAB TCF consent string from the events you create for users.
To generate an IAB TCF consent string for the user, add the property $generate_tcfcs=true
to the query-string parameters of the request when creating an event. The consent string will be generated and added to the consents.tcfcs
property of the event response and stored in the API.
Example
And the response will be:
Parameters
The generated TCF consent string can be configured with parameters passed to the iab.tcf
property of the event. Those parameters must reflect how your CMP is configured to comply with the IAB TCF policies and the version of the TCF you are applying.
The fields of a TCF consent string are documented in the official IAB TCF documentation.
The following parameters can be passed to the iab.tcf
property of the event:
Parameter | Description | Required | Type | Default | Notes |
---|---|---|---|---|---|
| TCF version being used | No |
| 2 | |
| The ID of the CMP that is generating the consent string. | Yes |
| ||
| Version of the CMP implementation. | No |
|
| |
| Screen number in the CMP where consent was given. | No |
|
| |
| Two-letter ISO 639-1 language code in which the CMP UI was presented. | No |
|
| |
| Version of the IAB Global Vendor List when the user choices were collected. | No |
|
| Minimum GVL version supported is 81. |
| Indicates if non-standard texts were used in the consent notice. | No |
|
| |
| Indicates if the purpose one was disclosed ( | No |
|
| |
| Publisher ISO 3166-1 alpha-2 country code. | No |
|
| |
| Publisher restrictions that applied when the user choices were collected. | No |
| None |
Example
Here is an example of an event that will generate a TCF consent string with the user's consent for the purpose cookies
and some extra TCF parameters:
Publisher restrictions
Publisher restrictions can be specified in the iab.tcf.publisher_restrictions
property of the event.
Purpose IDs passed in the iab.tcf.publisher_restrictions[].purposeId
property are Didomi API IDs and not IAB TCF IDs.
Vendor IDs passed in the iab.tcf.publisher_restrictions[].vendors.ids
property are Didomi API IDs and not IAB TCF IDs.
Examples:
Purpose ID
cookies
should be passed for IAB TCF purpose ID1
.Vendor ID
google
should be passed for IAB TCF vendor ID755
.
Example
Purpose ID
The purpose ID (purposeId
property) defines which purpose the publisher restriction applies to.
It must be a Didomi API purpose ID and not an IAB TCF purpose ID. For instance, use the value cookies
for the IAB TCF purpose ID 1.
Vendor IDs
The vendor IDs (vendors.ids
property) defines which vendors the publisher restriction applies to.
It must be a list of Didomi API vendor IDs and not IAB TCF vendor IDs. For instance, use the value google
for the IAB TCF vendor ID 755.
If the restriction applies to all vendors (vendors.type
is set to all
), providing a list of vendor IDs is not required and will be ignored.
Vendors type
The vendors type (vendors.type
property) defines how the list of vendors that the publisher restriction applies to is defined.
Must be one of:
list
: The restriction is applied to the vendors listed in theids
property.all
: The restriction applies to all the vendors in the vendor list of the IAB TCF.
Restriction type
The restriction type (restrictionType
property) defines how the restriction applies to the vendors.
Must be one of:
allow
: Allow the configured vendors to process data for the purpose.disallow
: Prevent the configured vendors from processing data for the purpose.req-consent
: Require vendors to process the data for the purpose only under the consent legal basis.req-li
: Require vendors to process the data for the purpose only under the legitimate interest legal basis.
Purposes and vendors
The vendors and purposes fields in the consent string are automatically generated from the vendor and purpose IDs that the user has made choices for in the event (consents
property).
Unsupported TCF features
The following fields will not be supported when generating a TCF string through the API:
DisclosedVendors
Last updated