Documentation Index

Fetch the complete documentation index at: https://usercentrics.document360.io/llms.txt

Use this file to discover all available pages before exploring further.

Core API for Unity

Prev Next

This article is a reference for the methods available in the Core API for the following platforms:

  • Unity

For reference documentation of the Event API for the same platforms, see Event API for Unity.

For reference documentation for other platforms, see Core API or Event API for apps.

Initialization

Initialize

Configures and initializes Usercentrics after app launch. synchronous execution, which means when execution is done initialization is complete.

Usercentrics.Instance.Initialize((status) => {    // Success: Returns UsercentricsReadyStatus object}, (errorMessage) => {    // Failure: Returns non-localized error});

Completion Blocks

Type

Notes

status

UsercentricsReadyStatus

Provides information needed to know what action to take next. Show CMP banner to collect consent or apply already collected consent.

error

String

String with non-localized description.

ShowFirstLayer

Displays the first layer of the banner.

Usercentrics.Instance.ShowFirstLayer( (userResponse) => {    // Handle userResponse});

ShowSecondLayer

Displays the second layer of the banner.

Usercentrics.Instance.ShowSecondLayer(
    <showCloseButton> /* true/false */,
    (usercentricsConsentUserResponse) = > {
                                              // Handle userResponse
                                          });

Features

RestoreUserSession

Restore consents given by a user using its Controller ID.

Usercentrics.Instance.RestoreUserSession(<controllerId>, (status => {}), (errorString => {}));

ClearUserSession

Clear consents given by a user in its current session, check out the feature page.

Usercentrics.Instance.ClearUserSession((status) => {}, (errorString) => {});

AcceptAll

Signal to Usercentrics SDK that the Accept All button has been pressed by the user.

Usercentrics.Instance.AcceptAll();

DenyAll

Signal to Usercentrics SDK that the Deny All button has been pressed by the user.

Usercentrics.Instance.DenyAll();

GetFirstLayerSettings

For now, this method only returns First Layer data when using TCF Framework.

Usercentrics.Instance.GetFirstLayerSettings();

GetConsents

Retrieve a list of services with the consent choices.

Usercentrics.Instance.GetConsents();

Outputs

Type

Notes

consents

[UsercentricsServiceConsent]

List of Services with consent choices.

Helpers

Platform is supported

Returns whether the currently selected platform is supported by Usercentrics.

Usercentrics.Instance.IsPlatformSupported();

GetControllerID

Catch user events if you are using Third Party Analytics tools.
Returns a Usercentrics-generated ID that represents the consent collected by a user.

Usercentrics.Instance.GetControllerID();

Track

Track user events if you are building your own UI, and want to see these events in the Usercentrics Analytics Dashboard.

Usercentrics.Instance.Track(<usercentricsAnalyticsEventType>);

Get CMP Data

Get CMP related data set in the Admin Interface.

var cmpData = Usercentrics.Instance.GetCmpData();

var publishedApps = cmpData.publishedApps;var activeVariant = cmpData.activeVariantvar userLocation = cmpData.userLocation;

TCF 2.2 Specific Methods

GetTCFData

Retrieve all data related to TCF 2.2, as well as the consent string. (TCString) Your CMP configuration needs to be set for TCF, otherwise this object will be empty.

Usercentrics.Instance.GetTCFData((tcfData) => {
  var purposes = tcfData.purposes;
  var specialPurposes = tcfData.specialPurposes;
  var features = tcfData.features;
  var specialFeatures = tcfData.specialFeatures;
  var stacks = tcfData.stacks;
  var vendors = tcfData.vendors;

// TCString    var tcString = tcfData.tcString;});

Set CMP ID

When building your own UI for TCF 2.2. You need to pass the CMPID given to you by the IAB, in order for your solution to be compliant.

Usercentrics.Instance.SetCmpId(<cmpId>);

GetAdditionalConsentModeData

Retrieve all data related to Google Additional Consent v2, as well as the consent string. (ACString) Your CMP configuration needs to be set for Additional Consent, otherwise this object will be empty.

var additionalConsentData = Usercentrics.Instance.GetAdditionalConsentModeData()

Outputs

Type

Notes

additionalConsentData

AdditionalConsentModeData

Retrieves the Google's Additional Consent String and the List of consented and not consented Ad Tech Providers.

CCPA/CPRA Specific Methods

Get CCPA/CPRA (USP) Data

Retrieve all data related to CCPA/CPRA, as well as the consent string. (USPString) Your CMP configuration needs to be set for CCPA/CPRA, otherwise this object will be empty.

Usercentrics.Instance.GetUSPData();

Objects

UsercentricsReadyStatus

Contains information about customer configuration from loaded properties during initialization.

Property

Type

Notes

shouldCollectConsent

Bool

True, if consent has never been collected or some service has changed thus requiring a consent update. False, if consent has been collected and no update is required.

consents

[UsercentricsServiceConsent]

List of Services with consent choices.

location

[UsercentricsLocation]

Current location of User.

geolocationRuleset

[GeolocationRuleset]

Object containing information about Geolocation Rulesets, when enabled in the account.

UsercentricsServiceConsent

The current consent status of a specific service.

Property

Type

Notes

templateId

String

ID used to match a service with frameworks running on your app. See Applying Service Consent.

status

Bool

Consent status given to this specific service.

history

[UsercentricsConsentHistoryEntry]

The consent history chronologically ordered.

dataProcessor

String

Name of entity processing the data that was collected via this service.

version

String

Legal template version. See Service Settings.

isEssential

Boolean

If it is an essential service.

type

UsercentricsConsentType

The type of the current consent status (Explicit/Implicit).

UsercentricsLocation

Contains information about the current location of the user.

Property

Type

Notes

countryCode

String

The country associated with the User's IP address. This is a Unicode CLDR region code, such as US or FR. (For most countries, these codes correspond directly to ISO-3166-2 codes.

regionCode

String

Region, e.g. a province or state, of the country associated with the User's IP address. This is a Unicode CLDR subdivision ID, such as USCA or CAON. (These Unicode codes are derived from the subdivisions defined by the ISO-3166-2 standard.

GeolocationRuleset

Contains information about Geolocation Rulesets, when enabled in the account.

Property

Type

Notes

activeSettingsId

String

Given a Ruleset can contain multiple Settings IDs, this property will have the value of the active one, chosen given User's location.

bannerRequiredAtLocation

Bool

Rulesets can be configured to not show the CMP in some locations, this propery will indicate wether the banner is required to be displayed or not.

UsercentricsConsentHistoryEntry

Contains information about a specific consent given at some point in the past, i.e. a consent history entry.

Property

Type

Notes

status

Bool

Consent status given to this specific service.

dataProcessor

String

Name of entity processing the data that was collected via this service.

timestampInMillis

Long

The UNIX timestamp in millisecons of the consent.

AdditionalConsentModeData

Contains Google's Additional Consent Mode Data.

Property

Type

Notes

acString

String

A String that represents the consented and disclosed Google Ad Technology Providers (ATPs), as defined by Google.

adTechProviders

List<AdTechProvider>

Represents the List of the defined ATPs.

AdTechProvider

Contains information about an Ad Tech Provider.

Property

Type

Notes

id

Int

ATP Identifier.

name

String

ATP Name.

privacyPolicyUrl

String

ATP Privacy Policy URL.

consent

Boolean

Consent given to the ATP.