Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • default

Index

Constructors

constructor

  • Parameters

    • ucId: string

      Your unique Usercentrics Id - settingsId or rulesetId

    • Optional options: InitOptions

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

    Returns default

CCPA Methods

getCcpaOptOutStatus

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

    Returns boolean

saveDefaultForCcpa

  • saveDefaultForCcpa(): Promise<void>
  • Don't perform any changes on consent level. Stores the timestamp and set userActionPerformed

    Returns Promise<void>

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

    • consentType: CONSENT_TYPE = CONSENT_TYPE.EXPLICIT

    Returns Promise<void>

General Methods

areAllConsentsAccepted

  • areAllConsentsAccepted(): boolean
  • Return if the user accepted all consents

    Returns boolean

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>

getAriaLabels

  • getAriaLabels(): LegacyAriaLabelsTranslations
  • Retrieve aria labels

    Returns LegacyAriaLabelsTranslations

getControllerId

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

    Returns string

getSettings

getSettingsCore

  • getSettingsCore(): Core

getSettingsData

getSettingsLabels

getSettingsUI

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(): Promise<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 Promise<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

    • consentType: CONSENT_TYPE = CONSENT_TYPE.EXPLICIT

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

    Returns Promise<void>

denyAllServices

  • 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

    • 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

getCategories

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

    deprecated

    since version 2.2.0-beta.3 Will be deleted in version 3.0.

    In case you need similar behavior, use getCategoriesBaseInfo or getCategoriesFullInfo

    Returns Category[]

getCategoriesBaseInfo

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

    Returns BaseCategory[]

getCategoriesFullInfo

  • getCategoriesFullInfo(): Promise<Category[]>
  • Retrieve the categories and their full services info to display this information in your UI.

    Returns Promise<Category[]>

getServices

  • Retrieve all services.

    deprecatedsince

    version 2.2.0-beta.3 Will be deleted in version 3.0.

    In case you need similar behavior, use getServicesBaseInfo or getCategoriesFullInfo

    Returns Service[]

getServicesBaseInfo

getServicesFullInfo

  • getServicesFullInfo(): Promise<Service[]>
  • Retrieve all services fetching the aggregator if necessary.

    Returns Promise<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)

    • 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

acceptAllAmp

  • acceptAllAmp(): Promise<void>
  • Accept all services for AMP

    Returns Promise<void>

clearStorage

  • clearStorage(): Promise<void>
  • Clear the storage from all buckets

    Returns Promise<void>

denyAllAmp

  • denyAllAmp(): Promise<void>
  • Reject all services for AMP

    Returns Promise<void>

dismissAmp

  • dismissAmp(): Promise<void>
  • Dismiss UI for AMP - this closes the AMP UI and also don't change the consent. If a consent has already been given, AMP uses that as the current state.

    Returns Promise<void>

enableScriptsForServicesWithConsent

  • enableScriptsForServicesWithConsent(): void
  • Needed for enabling dynamically loaded script.

    Returns void

enterFullscreenAmp

  • enterFullscreenAmp(): Promise<void>
  • Enter fullscreen mode on AMP UI

    Returns Promise<void>

getAbTestVariant

  • getAbTestVariant(): string
  • Retrieve ab testing variant in use.

    Returns string

loadServices

  • loadServices(): Promise<void>
  • Fetch service data from the aggregator if the data wasn't fetched already

    Returns Promise<void>

loadSettings

  • loadSettings(): Promise<LegacySettings>

postMessageAmp

  • postMessageAmp(type: AMP_CONSENT_TYPE, action: AMP_CONSENT_ACTION, initialHeight?: string): Promise<void>
  • This method sends the message to the parent iframe to communicate the user's decisions

    Parameters

    • type: AMP_CONSENT_TYPE

      the AMP consent type

    • action: AMP_CONSENT_ACTION

      the AMP consent action

    • Optional initialHeight: string

    Returns Promise<void>

saveTCFDataAmp

  • saveTCFDataAmp(userDecisions: UserDecision[]): Promise<void>
  • Save current TCF data based on user decisions according to the rules below:

    • if there are only TCF vendors and no non-IAB-service - we signal accept
    • if the are non-IAB services and ALL of them have a consent we signal accept
    • if the are non-IAB services and at least ONE of them has NO consent we signal reject

    Parameters

    Returns Promise<void>

setTrackingPixel

uiReadyAmp

  • uiReadyAmp(): Promise<void>
  • Sends the ready message to display the AMP UI

    Returns Promise<void>

updateLayer

  • updateLayer(activeLayer: UI_LAYER): Promise<void>

updateStorage

  • updateStorage(storageDataTransferObjects?: DataTransferObject[]): Promise<void>
  • Parameters

    • Optional storageDataTransferObjects: DataTransferObject[]

    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, 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 null | 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>