Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Usercentrics

Hierarchy

  • Usercentrics

Index

Constructors

constructor

  • Parameters

    • settingsId: string

      Your unique Usercentrics settingsId

    • Optional options: InitOptions

      Additional options for initialization of the SDK. Note especially the createTcfApiStub property which is necessary for TCF UIs.

    Returns Usercentrics

CCPA Methods

getCcpaOptOutStatus

  • getCcpaOptOutStatus(): boolean
  • Retrieve optout status of ccpa

    Returns boolean

saveOptOutForCcpa

  • saveOptOutForCcpa(isOptedOut: boolean, consentType?: CONSENT_TYPE): Promise<void>
  • Set optout status in cookie for user and save string in backend

    Parameters

    • isOptedOut: boolean

      User's decision on all consents

    • Default value consentType: CONSENT_TYPE = CONSENT_TYPE.EXPLICIT

    Returns Promise<void>

General Methods

changeLanguage

  • changeLanguage(language: string): Promise<void>
  • Change the language. All upcoming SDK calls will return information in this language (e.g. getSettings(),getCategories(), getTCFData(), ...). Pay attention that the language needs to be set up in your Usercentrics Admin Interface before!

    Parameters

    • language: string

      The language to switch to (ISO 639-1 code)

    Returns Promise<void>

getControllerId

  • getControllerId(): string
  • Retrieve the controllerId, that's generated for the user.

    Returns string

getSettings

  • Retrieve all settings.

    Returns Settings

init

  • Initializes the Usercentrics framework. This method must be called when loading your website. The return value defines which UI layer & variant you should initially show for your users.

    Returns Promise<InitialUIValues>

saveUserActionPerformed

  • saveUserActionPerformed(): void
  • Set user action performed. Only needed if a user action is performed without the need for an explicit consent (e.g. CCPA first layer implementation)

    Returns void

Non-TCF Methods

acceptAllServices

  • acceptAllServices(consentType?: CONSENT_TYPE): Promise<void>
  • Mark all services as "Consent given" (e.g. an "Accept All" button was clicked). The SDK will store the consent information and trigger events depending on your Usercentrics Settings.

    Parameters

    • Default value consentType: CONSENT_TYPE = CONSENT_TYPE.EXPLICIT

      The manner in which the consent was given (explicit vs. implicit). Default: explicit.

    Returns Promise<void>

denyAllServices

  • denyAllServices(consentType?: CONSENT_TYPE): Promise<void>
  • Mark all services as "Consent denied" (e.g. a "Deny All" button was clicked). Essential services will still be marked as "Consent given". The SDK will store the consent information and trigger events depending on your Usercentrics Settings.

    Parameters

    • Default value consentType: CONSENT_TYPE = CONSENT_TYPE.EXPLICIT

      The manner in which the consent was denied (explicit vs. implicit). Default: explicit.

    Returns Promise<void>

fetchIsUserInEU

  • fetchIsUserInEU(): Promise<boolean>
  • Retrieve boolean, that can be used to decide if the user is inside the EU or not.

    Returns Promise<boolean>

fetchUserCountry

  • Retrieve the user's country information.

    Returns Promise<UserCountry>

getCategories

  • Retrieve the categories and their services to display this information in your UI.

    Returns Category[]

getServices

  • Retrieve all services.

    Returns Service[]

restoreUserSession

  • restoreUserSession(controllerId: string): Promise<void>
  • Restore a session for an end user with the given controllerId.

    Parameters

    • controllerId: string

      User's generated controllerId. NOTE: Always use a controllerId provided by the SDK.

    Returns Promise<void>

updateServices

  • Mark given services as "Consent given / denied". Essential services will still be marked as "Consent given". The SDK will store the consent information and trigger events depending on your Usercentrics Settings.

    Parameters

    • decisions: UserDecision[]

      The user's decisions for individual services (see interface definition for details)

    • Default value consentType: CONSENT_TYPE = CONSENT_TYPE.EXPLICIT

      The manner in which the consent was given/denied (explicit vs. implicit). Default: explicit.

    Returns Promise<void>

Other Methods

isCcpaEnabled

  • isCcpaEnabled(): boolean
  • Get the information If CCPA is enabled for current user of not

    Returns boolean

TCF Methods

acceptAllForTCF

  • Mark all disclosed TCF vendors, purposes, specialFeatures as "consent given" and if applicable "legitimate interest given". The SDK will store the consent information and trigger TCF events. NOTE: This function will also mark the TCF UI as being closed! No need to call the setTCFUIAsClosed() method.

    Parameters

    • fromLayer: TCF_DECISION_UI_LAYER

      The layer from which the consent was given/denied (firstLayer vs. secondLayer).

    Returns Promise<void>

denyAllForTCF

  • Mark all disclosed TCF vendors, purposes, specialFeatures as "consent denied" and if applicable "legitimate interest denied". The SDK will store the consent information and trigger TCF events. NOTE: This function will also mark the TCF UI as being closed! No need to call the setTCFUIAsClosed() method.

    Parameters

    • fromLayer: TCF_DECISION_UI_LAYER

      The layer from which the consent was given/denied (firstLayer vs. secondLayer).

    Returns Promise<void>

getTCFData

  • Retrieve all TCF data, including consents and descriptions for TCF vendors, purposes, special purposes, features, special features, and stacks Only vendors and stacks that have been selected in the admin interface will be returned. Only purposes, features, special features, special purposes that are used by one or more of the selected vendors (and/or selected stacks) will re returned.

    Returns TCFData

setTCFUIAsClosed

  • setTCFUIAsClosed(): Promise<void>
  • Mark the TCF UI as being closed and trigger related TCF events. NOTE: Remember to call this ALWAYS when an end-user closes your TCF UI without making any changes!

    Returns Promise<void>

setTCFUIAsOpen

  • setTCFUIAsOpen(): Promise<void>
  • Mark the TCF UI as being open and trigger related TCF events. NOTE: Remember to call this ALWAYS when an end-user opens up your TCF UI!

    Returns Promise<void>

updateChoicesForTCF

  • Mark given TCF vendors, purposes, specialFeatures as "consent given / denied" and if applicable "legitimate interest given denied". The SDK will store the consent information and trigger TCF events. NOTE: This function will also mark the TCF UI as being closed! No need to call the setTCFUIAsClosed() method.

    Parameters

    • decisions: TCFUserDecisions

      The user's decisions for individual TCF vendors, purposes, specialFeatures (see interface definition for details)

    • fromLayer: TCF_DECISION_UI_LAYER

      The layer from which the consent was given/denied (firstLayer vs. secondLayer).

    Returns Promise<void>