TrustCommander (deprecated)
Community home
English
English
  • Overview
  • Responsability of actors
  • Releases notes
  • Setup Guides
    • Tag Manager
      • TagCommander
      • Google Tag Manager (GTM)
      • Consent Mode
      • Consent Mode in GTM
      • Adobe Launch
    • Websites (Hardcoded)
    • Mobile apps
      • iOS
        • ATT - App Tracking Transparency (iOS 14.5+)
      • Android
  • User Guides
    • Categories & Tags
      • Manage Categories
      • Manage Vendors
      • Assign Categories
    • Privacy Banners
      • Banner Templates
        • Accessibility Template
      • Manage Banner
      • Deploy Banner
      • Copy Banner
    • Dashboard
    • Exports
    • Options
  • Extensions
    • Cookie Scanner
    • TagFirewall
    • Tag Hierarchy
  • Marketing Preferences Center
    • Marketing Preferences Center (Trust Premium only)
  • Knowledge Base
    • Consent Object
    • TrustCommander cookies exemption
    • Consent Cookie
    • IAB TCF V2.0 Consent
    • IAB TCF V2.0 and Google FAQ
  • Rest data API
    • GET/PUT Consents / preferences
  • Onsite API
    • Getting Started
    • consent.get
    • consent.update
    • consent.revoke
    • consent.onUpdate
    • consent.onReady
    • consentBanner.show
    • consentBanner.hide
    • consentCenter.show
    • consentCenter.hide
  • PLATFORM API
    • Get statistics
Powered by GitBook
On this page
  • How to use the TCF API
  • How to decode the Consent-String
  • Google Additional Consent Mode
  1. Knowledge Base

IAB TCF V2.0 Consent

Description of how to interact with IAB consent API

PreviousConsent CookieNextIAB TCF V2.0 and Google FAQ

Last updated 4 years ago

If you are using IAB TCF option (see to setup IAB TCF on your account), you will be able to use IAB TCF's __tcfapi where your privacy banner is deployed.

That function is defined in your container and in your privacy banner so that you can use it before your privacy banner has finished loading. It is sometimes referred by IAB as the TCF API stub.

IAB TCF consent is encoded in a format called the Consent-String.

How to use the TCF API

The recommended way of getting the value of TCF's consent-string (tcData.tcString in the example below) is by using the addEventListener command.

__tcfapi('addEventListener', 2, function(tcData, success) {
  if(success &&
    (tcData.eventStatus === 'tcloaded' || tcData.eventStatus === 'useractioncomplete')) {

    // do something with tcData.tcString

  } else {

    // do something else

  }
});

Sometimes you do not want to be notified of consent updates. You can achieve this by using the more advanced code below:

__tcfapi('addEventListener', 2, function(tcData, success) {
  if(success &&
    (tcData.eventStatus === 'tcloaded' || tcData.eventStatus === 'useractioncomplete')) {

    // do something with tcData.tcString

    // remove ourselves to not get called more than once
    __tcfapi('removeEventListener', 2, tcData.listenerId);

  } else {

    // do something else

  }
});

How to decode the Consent-String

Google Additional Consent Mode

This an optional extension to IAB TCF. Once setup in TrustCommander Options, an additional addtlConsent property will be available on the tcData object.

__tcfapi('addEventListener', 2, function(tcData, success) {
  if(success &&
    (tcData.eventStatus === 'tcloaded' || tcData.eventStatus === 'useractioncomplete')) {

    // do something with tcData.addtlConsent

  } else {

    // do something else

  }
});

Reference:

You can use this copy-paste a Consent-String on this page: .

Reference:

Reference:

this page
IAB TCF commands
https://iabtcf.com/#/decode
IAB TCF Consent-String format
Google Additional Consent Mode Technical Specification