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

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>

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>

acceptAllServicesInCategory

  • acceptAllServicesInCategory(categorySlug: string, consentType?: CONSENT_TYPE): Promise<void>
  • Mark all services in a given category as "consent given". The SDK will store the consent information and trigger events depending on your Usercentrics Settings.

    Parameters

    • categorySlug: string

      Category identifier.

    • 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. an deny all button was clicked). Essential services will still be marked as accepted. 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>

denyAllServicesInCategory

  • denyAllServicesInCategory(categorySlug: string, consentType?: CONSENT_TYPE): Promise<void>
  • Mark all services in a given category as "consent denied". Essential services will still be marked as accepted. The SDK will store the consent information and trigger events depending on your Usercentrics Settings.

    Parameters

    • categorySlug: string

      Category identifier.

    • 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[]

getEssentialCategories

  • Retrieve the categories that are marked as essential and their services.

    Returns Category[]

getEssentialServices

  • getEssentialServices(): Service[]
  • Retrieve all services that are considered essential, because they are placed inside an essential category.

    Returns Service[]

getNonEssentialCategories

  • getNonEssentialCategories(): Category[]
  • Retrieve the categories that are marked as non-essential and their services.

    Returns Category[]

getNonEssentialServices

  • getNonEssentialServices(): Service[]
  • Retrieve all services that are considered non-essential, because they are placed inside an non-essential category.

    Returns Service[]

getServices

  • Retrieve all services.

    Returns Service[]

updateServices

  • Mark given services as "consent given / denied". Essential services will still be marked as accepted. 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>

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. Only vendors 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 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>