Cross-Device Consent Sharing

ConsentManager supports Cross-Device Consent Shareing. In order to share consent information across multiple devices, the website needs to meet the following requirements:

  • The website needs to be able to identify the user across devices. This is usually done via a login on the website: Every time the user logs into the account, the (new) device can share the same consent information as all other devices of the same user.
  • The website needs to be able to store the consent information of the user on the server side. The consent information will be an alphanummeric string with up to 4kb size

General setup

In order to share the consent across multiple devices, the following steps will be performed:

  1. When the user visits the website first, no consent information is present and the user will be asked for consent.
  2. Once the user gives consent, the CMP will store the consent information on the users device and notify the website that new consent information is present.
  3. The website will retrieve/export the consent information from the CMP and store it in its own database along with the users profile.
  4. The next time the user visits the website, the website will import the existing consent information into the CMP.

Sample code setup

In order export the consent information, the command __cmp('exportConsent') can be used. It will output the consent information as a base64 encoded websafe string.

In order to import the existing information, the command __cmp('importConsent','....') can be used. It will set the internal consent information and disable the consent screen.

Please note: In order to avoid that the consent screen is shown, the command importConsent should be called immediatly after the CMP-Code. The CMP will queue the command and automatically import the consent information as a first step when loading the CMP.

Here is an simple example code that will perform the import, check for changes and export the consent data if necessary:

  var userConsentInfo = '... insert consent data from users profile if present, otherwise empty ...';
  function storeConsent(eventname, o)
   var c = __cmp("exportConsent");
   if(c !== userConsentInfo)
    console.log('new consent data: ', c);
    userConsentInfo = c;
     //send new consent info to server in order to store it there
  __cmp('addEventListener', ['consent', storeConsent, false], null);
Back to top