Skip to content

Unity Core API

Initialization

Init

Called to configure and initialize Usercentrics after app launch

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

When called, it will display First Layer.

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

ShowSecondLayer

When called, it will display the Second Layer.

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.

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.activeVariant
var 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

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

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

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

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

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

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

Property Type Notes
id Int ATP Identifier.
name String ATP Name.
privacyPolicyUrl String ATP Privacy Policy URL.
consent Boolean Consent given to the ATP.