Didomi - Developers documentation
  • Introduction
  • SDKs
    • Introduction
    • Web SDK
      • Getting started
      • Tags and vendors management
        • Tags management
          • Events & Variables
            • Deprecated
            • Custom events
          • Tag managers
            • Adobe Launch/DTM
            • Eulerian
            • Google Tag Manager
              • Configure the Didomi / GTM integration
              • Didomi's GTM template
            • Tealium
            • Other tag managers
        • Custom Didomi <script> tags
        • Third-party integrations
          • Google Ad Manager / AdSense
            • GDPR via Non-Personalized Ads
              • Share consent and load/refresh ads
              • Share consent without loading or refreshing ads
            • US states laws
          • Google Consent Mode V2
          • Kameleoon
          • Piano Analytics (AT Internet)
          • Prebid
            • GDPR via IAB TCF
            • US states laws
          • Salesforce DMP (Krux)
        • IAB frameworks
        • Programmatic API
      • Configuration
        • Bots (SEO & Performance tools)
        • Configuration by URL
        • Cookies and storage
        • Custom domains for events
        • Notice
          • Behavior
          • Interactions
          • Look and feel
        • Preferences
        • Theme
      • AB tests
      • Custom domain
        • Domain delegation
        • Reverse proxy
      • Share consents between domains
      • Share consents across devices
      • Pass user choices in query string
      • Serve Didomi assets from your domain
      • Reference
        • API
          • Deprecated
        • Events
      • Performance
      • Versions
    • Mobile and TV SDKs
      • Android and Android TV
        • Setup
        • Logging
        • Reference
          • API
            • Deprecated
          • Events
        • Versions
      • iOS and tvOS
        • Setup
        • Logging
        • App Tracking Transparency (iOS 14.5+)
        • Reference
          • API
            • Deprecated
          • Events
        • Versions
      • Unity
        • Setup
        • Reference
        • Versions
        • Troubleshooting
      • React Native
        • Setup
        • Reference
          • Deprecated
        • Versions
      • Flutter
        • Setup
        • Reference
        • Versions
      • Consent notice
        • Getting started
        • Customize the notice
        • Customize the preferences popup
        • Customize the theme & UI
        • Load notice by ID
      • Third-party SDKs
      • Share consents across devices
      • Share consent with WebViews
      • Google Consent Mode v2
      • FAQ
    • AMP SDK
      • Blocking Behaviors
        • Load immediately on page load
        • Load only after consent (positive or negative)
        • Load only after positive consent
      • Consent status for vendors
    • Help & Support
  • API
    • Introduction
      • Authentication
      • Errors
      • Pagination
      • Filters
      • Caching
      • Rate limiting
      • Quotas
      • Translations
    • Data Manager
      • Regulations
      • Configuration Tree
      • Purposes
        • Purposes & Vendors Numerical IDs
      • Preferences Library
      • User Rights
    • Widgets
      • Consent notices
        • Notices
        • Configurations
        • Multi-Regulation Configurations
          • Migration of Existing Notices and API Updates
        • Deployments
        • Tutorials
          • Create and publish a consent notice
          • Create and publish a multi-regulation consent notice
      • Privacy widgets
        • Create a widget
        • Retrieve widgets
        • Edit a widget
          • Content & Design
            • Themes & Shapes
            • Components
              • auth
              • dsar_form
              • footer
              • header
              • preference
              • preference_value
              • save
              • section
              • sections
            • Options
          • Purposes & preferences
          • Settings
        • Deploy a Widget
          • Use your own subdomain
          • Use your own domain
          • Implement an embeddable widget on your website
        • Authentication
          • Manage authentication providers
          • Authenticate your end-user
        • Archive a widget
        • Headless widgets
          • Public Methods
          • Custom elements
          • Custom events
          • Event listeners
        • Tutorial
          • Launch a Preference Center from a mobile app
    • Compliance Reports
      • Properties
      • Reports
      • CSV format reference
      • Websites
    • Consents and Preferences
      • Events
        • Generate IAB TCF consent string
      • Links
      • Proofs
      • Tokens
      • Secrets
      • Users
      • Tutorial
        • Collect and operate data
    • Privacy Requests
      • Requests
      • Notes
      • Links
      • Emails
  • Integrations
    • Introduction
      • Quotas
    • Generic integrations
      • Batch export
        • Destinations
          • AWS S3 Bucket (owned by Didomi)
          • GCP Storage Bucket
        • Exported data
          • Notices consents
        • Logs
      • Webhooks
      • Batch import
      • Analytics export
        • Destinations
          • AWS S3 Bucket (owned by Didomi)
          • GCP Storage Bucket
    • Third-party apps
      • CMP integrations
        • Didomi-mParticle integration for your CMP
        • Deploy Didomi’s SDK for your Adobe Commerce website
      • Preference Management Platform integrations
        • Actito
        • Adobe Campaign Classic
        • Adobe Experience Cloud
        • Adobe Marketo Engage
        • Adobe Source Connector
        • Braze
        • Dotdigital
        • Hubspot
        • Mailchimp
        • Microsoft Dynamics 365
        • Salesforce Marketing Cloud
        • Salesforce Sales & Service Cloud
        • Selligent
        • Brevo (ex Sendinblue)
    • Tutorials
      • Configure a HTTP webhook
      • Configure a batch export
      • Configure an analytics export
    • Emailing
      • Configurations
        • Actito Email
        • Actito SMS
        • Adobe Campaign Classic
        • Adobe Campaign Standard
      • Emails
        • Templates
        • Manage your templates
Powered by GitBook
On this page
  1. API
  2. Widgets
  3. Privacy widgets
  4. Headless widgets

Public Methods

PreviousHeadless widgetsNextCustom elements

Last updated 1 year ago

Public methods are SDK methods that are made available to facilitate your interactions with our SDK, including getting information from the widget configuration and from the current user consent state.

DidomiWidgets.getContainerById(widgetId)

The SDK allows you to get the configuration object of a published widget using the getContainerbyId method.

const container = await DidomiWidgets.getContainerById("widgetId");

We recommend getting the widget's configuration once the SDK is ready. You can refer to the example .

DidomiWidgets.updateToken(token)

The SDK allows you to set the user token asynchronously.

const container = await DidomiWidgets.updateToken(YOUR_TOKEN);

container.getEntities()

The SDK provides a method called getEntities that enables you to retrieve entities from your Configuration Tree that are enabled in your widget. From there, you will be able to display purpose and preference choices on your page using our .

  const entities = await container.getEntities();

container.isConsentPurposeEnabled(purposeId)

The SDK provides a method for checking whether a purpose is enabled or not.

The method, isConsentPurposeEnabled(purposeId) takes the purpose ID as a parameter and returns true or false.

const isPurposeEnabled = container.isConsentPurposeEnabled(purposeId)

container.getPreferenceValueById({ purposeId, preferenceId })

The SDK provides a method for fetching choices selected from a preference.

The method getPreferenceValueById takes the purpose ID and preference ID as parameters and returns a string of IDs separated by commas (,) containing the enabled values.

const enabledValuesAsString = container.getPreferenceValueById({ purposeId, preferenceId });a

container.getEntityContentById({ entityType, entityId, entityProperty, withComponentContent })

The SDK offers a method for displaying the translated content of your entities if you are unable to use our custom elements.

The method getEntityContentById takes the entityType, entityId, entityProperty and withComponentContent as parameters and returns a string with the content requested.

Parameter
Description

entityType

This property determines which content of the entity object should be displayed. It can be name or description.

entityId

ID of the selected purpose, selected preference or preference value. You can easily find them in the Configuration Tree section on the Console.

entityProperty

Specify the type of property. It can be either purpose, preference or preference-value.

withComponentContent

This property is used to determine whether to override the entity content with the layout component one set a widget level, if any (true), or to display the entity content (undefined).

container.getComponentContentById({ componentId, componentProperty })

The SDK offers a method for displaying the translated content of your component if you are unable to use our custom elements.

The method getComponentContentById takes the containerId, componentId and componentCategory as parameters and returns a string with the content requested.

Parameter
Description

componentId

ID of the layout-component

componentProperty

Property of the layout-component. For example saveButton.text.content (if it has been edited at the layout-component level) or bannerImage.src to get the URL of the header banner image for instance.

You will receive the following data. We recommend getting the widget's configuration once the SDK is ready. You can refer to the example .

DidomiWidgets.getContainerById(widgetId)
DidomiWidgets.updateToken(token)
container.getEntities()
container.isConsentPurposeEnabled(purposeId)
container.getPreferenceValueById({ purposeId, preferenceId })
container.getEntityContentById({ entityType, entityId, entityProperty, withComponentContent })
container.getComponentContentById({ componentId, componentProperty })
here
Custom Elements
here