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
});

Show UsercentricsUI First Layer

When called, it will display First Layer. Note that <UsercentricsLayout?> argument is optional.

Usercentrics.Instance.ShowFirstLayer(<UsercentricsLayout?>, (userResponse) => {
    // Handle userResponse
});

Show UsercentricsUI Second Layer

When called, it will display the Second Layer.

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

Features

Restore user session

Restore Consents given by a user using its Controller ID.

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

Reset

Resets Usercentrics SDK, deleting all local data and forcing to be initialized again.

Usercentrics.Instance.Reset();

Accept All

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

Usercentrics.Instance.AcceptAll();

Deny All

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

Usercentrics.Instance.DenyAll();

Get FirstLayerSettings

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

Usercentrics.Instance.GetFirstLayerSettings();

Helpers

Platform is supported

Get if current selected platform is supported by Usercentrics.

Usercentrics.Instance.IsPlatformSupported();

Get Controller ID

Usercentrics.Instance.GetControllerID();

Track

Track events made by the user in order to be displayed in the 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.0 Specific Methods

Get TCF Data

Retrieve all data related to TCF 2.0, 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 builing your own UI for TCF 2.0. You need to pass the CMPID given to you by the IAB, in order for your solution to be compliant.

Usercentrics.Instance.SetCmpId(<cmpId>);

CCPA Specific Methods

Get CCPA (USP) Data

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

Usercentrics.Instance.GetUSPData();