Usercentrics CMP Browser SDK
With the Usercentrics CMP Browser SDK our aim is to provide a lightweight library which enables you to build your own fully customized Consent Solution while still leveraging the Usercentrics service database and tools.
We also offer collaboration possibilities with Usercentrics Partners who are able to support you in building your own customized solution. Contact our sales team for more information.
Installing the dependency
npm install @usercentrics/cmp-browser-sdk --save
NOTE: We currently offer the SDK only as a CommonJS package.
Initialization
import Usercentrics, { INITIAL_VIEW } from '@usercentrics/cmp-browser-sdk';
const UC = new Usercentrics('YOUR_USERCENTRICS_SETTINGS_ID');
UC.init().then(initialView => {
const categories = UC.getCategories();
const settings = UC.getSettings();
switch (initialView) {
case INITIAL_VIEW.FIRST_LAYER:
return;
case INITIAL_VIEW.PRIVACY_BUTTON:
return;
case INITIAL_VIEW.NONE:
default:
return;
}
});
The constructor also supports an optional Options parameter.
Changing the language
import Usercentrics, { INITIAL_VIEW } from '@usercentrics/cmp-browser-sdk';
const UC = new Usercentrics('YOUR_USERCENTRICS_SETTINGS_ID');
UC.init().then(initialView => {
UC.changeLanguage('NEW_LANGUAGE').then(() => {
const categories = UC.getCategories();
const settings = UC.getSettings();
});
});
Documentation
Documentation can be found on our documentation website.