Integration consent manager¶
The Datastreams consent manager is an essential tool to guarantee compliance with the data protection laws.
The manager should have been configured on the Datastreams Platform using the Privacy & Compliance module. It’s recommended to use an incognito browser instance without any adblocking software activated.
dsmConsent methods¶
Get the status of the popup. If this method returns true
, the user has not made a choice yet.
dsmConsent.shouldShowPopup()
// true
Obtain consent choices made.
If the values are null
, no choices have been made yet. The value 0
stands for rejected and the value 1
stands for accepted.
dsmConsent.choices()
// {analytics: 1, anonymous: 0, social: 1}
Get consent choices made in detail.
dsmConsent.getDetailed()
// analytics: {id: 'aLzfuiog3f', version: 1, title: 'This website uses analytical cookies.', text: 'We use analytical cookies to improve our website.', defaultValue: 1, …}
// anonymous: {id: 'auzf1iogXf', version: 1, title: 'Keep me anonymous.', text: 'Do not collect personal information.', accepted: 0}
// social: {id: 'auza1iogXd', version: 1, title: 'I agree on social cookies.', text: 'Facebook uses cookies for personalization and recommendation.',
Asynchronous integration¶
It’s recommended to load all your JavaScript assets async, this speeds up the page load times. When loading your assets async one can not assume that the consent code has been loaded and initialized yet.
Use the code below to call a method after loading the Dperms code.
function functionAfterDperms() {
// Logic after initialization of the Dperms library...
}
if (typeof Dperms !== "undefined" && Dperms.isSynced()) {
functionAfterDperms()
} else {
window.addEventListener("Dperms", functionAfterDperms);
}
You can register in a similar fashion on consent events to load third-party scripts.
Use the code below to register consent choices made.
function registerConsentChange() {
Dperms.bus.register("Dperms.change",()=> {
console.log(dsmConsent.getDetailed())
// Load third-party scrips here based on the
// detailed consent purpose status.
});
}
if (typeof Dperms !== "undefined" && Dperms.isSynced()) {
registerConsentChange()
} else {
window.addEventListener("Dperms", registerConsentChange);
}