TCF v2.0 Consent

Warning.

This is an archived version of the documentation. Actual documentation for all platforms can be found here.

If you implemented a consent management platform (CMP) that complies with the IAB Transparency and Consent Framework (TCF) v2.0 for obtaining consent from the end user to transfer their personal data (user consent flow), Yandex Mobile Ads SDK supports sending TCF v2.0 values.

Yandex Mobile Ads SDK retrieves TCF v2.0 consent strings from SharedPreferences using the following keys:

IABTCF_TCString String Full encoded TC string.
IABTCF_gdprApplies Number
  • 1: GDPR applies in the current context.
  • 0: GDPR doesn't apply in the current context.
  • Unset: Unknown (default before initialization).
IABTCF_CmpSdkID Number Unsigned integer ID of the CMP SDK used.
IABTCF_PurposeConsents Binary string

“0” or “1” at position n, where n's indexing begins at 0. Indicates the consent status for purpose ID n+1. “0” corresponds to false, and “1” corresponds to true. For example, “1” at index 0 is consent true for purpose ID 1.

IABTCF_VendorConsents Binary string

“0” or “1” at position n, where n's indexing begins at 0. Indicates the consent status for vendor ID n+1. “0” corresponds to false, and “1” corresponds to true. For example, “1” at index 0 is consent true for vendor ID 1.

IABTCF_TCString String Full encoded TC string.
IABTCF_gdprApplies Number
  • 1: GDPR applies in the current context.
  • 0: GDPR doesn't apply in the current context.
  • Unset: Unknown (default before initialization).
IABTCF_CmpSdkID Number Unsigned integer ID of the CMP SDK used.
IABTCF_PurposeConsents Binary string

“0” or “1” at position n, where n's indexing begins at 0. Indicates the consent status for purpose ID n+1. “0” corresponds to false, and “1” corresponds to true. For example, “1” at index 0 is consent true for purpose ID 1.

IABTCF_VendorConsents Binary string

“0” or “1” at position n, where n's indexing begins at 0. Indicates the consent status for vendor ID n+1. “0” corresponds to false, and “1” corresponds to true. For example, “1” at index 0 is consent true for vendor ID 1.

For a detailed description, see the IAB documentation.

Passing values to SharedPreferences

Make sure to set required key values before making ad requests. There are two ways to do this:

Manually

Add the values for the keys from the table above to SharedPreferences. Example:

Kotlin
val sharedPref = activity?.getPreferences(Context.MODE_PRIVATE) ?: return
with (sharedPref.edit()) {
    putInt("IABTCF_gdprApplies", 1)
    apply()
}
Java
SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putInt("IABTCF_gdprApplies", newHighScore);
editor.apply();
Note.

For more information, see the documentation. The parameters depend on the country, user settings, and device.

Via a CMP SDK

TUse pre-configured CMP SDKs. These SDKs automatically pass the necessary values to SharedPreferences so that Yandex Mobile SDK can use them.