Privacy hub widget implementation overview

circle-info

Currently, the Privacy Hub widget does not have dedicated analytics. Any data gathered through the Privacy Hub will be integrated without distinction into the existing analytics framework, which includes metrics such as notice displays, consent records, and user preferences.

This guide provides detailed instructions on deploying the Privacy Hub widget using a provided script. For a live demonstration of the widget, visit didomi.ioarrow-up-right to see it in action.

Capture d’écran 2024-01-30 à 09.33.51

The script is versatile, allowing integration onto any website. It offers customization options for your widget's links and styling, ensuring it aligns with your site's aesthetic.

There are two methods to implement the Privacy Hub widget:

  • Loader Script: This approach streamlines deployment by automatically incorporating the necessary stylesheets. You only need to embed a single file into your HTML.

  • Base Script: This method requires you to manually integrate the stylesheets.

Deployment using the loader Script

To deploy the widget with the loader script, configure it via the privacyHubWidgetConfig property in the window object. This configuration object includes:

  • elementSelector: Defines the widget's placement on your site.

  • stylesheet: A link to a completely custom stylesheet for full design control. If unspecified, the widget uses default styles (details available herearrow-up-right). If this property is defined the style property will be ignored.

  • options: A list of objects detailing the widget's clickable options, each with a name and a link.

  • style: A list of objects, each with properties designed to tweak the widget's appearance (recommended option).

  • widgetSrc: An URL of the widget’s script to be loaded.

For reference: the path of the script that is being loaded is herearrow-up-right.

Example of loader script usage:

Deployment using the base Script

The privacy-hub-widget.js script exports an object (and creates a window.privacyHubWidget property) with functions for widget setup:

  • init(elementSelector = "", options = []): Initializes the widget. Specify the selector for the widget's location and the options to be displayed upon interaction.

  • createOptions(options = []): A utility function for generating the widget's clickable options.

  • createPrivacyHubButton(): A function for creating the widget's button.

HTML Layout + CSS Classes

The script generates a specific HTML structure (see below) with associated CSS classes. This structure serves as a reference for customizing or extending the base styles to better match your website's design.

Last updated