Cross-Device Consent Sharing
ConsentManager supports Cross-Device Consent Shareing. In order to share consent information across multiple devices, the website/app needs to meet the following requirements:
- The website/app needs to be able to identify the user across devices. This is usually done via a login on the website or app: 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.
- Your platform (the one that stores the login of the user) 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 8kb size
General setup
- When the user visits the website or app first, no consent information is present and the user will be asked for consent.
- Once the user gives consent, the CMP will store the consent information on the users device and notify the website or app that new consent information is present.
- The website or app will retrieve/export the consent information from the CMP and store it in its own database along with the users profile.
- The next time the user visits the website or app, it will import the existing consent information into the CMP.
Web
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.
As an alternative you can also pass the consent information via the URL using parameter ?cmpimport=...
or #cmpimport=...
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:
<script>
window.cmp_waitfortimport = 1000; // tell the CMP to wait for max 1 second for incoming import calls
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
}
}
if(userConsentInfo != "")
{
__cmp('importConsent',userConsentInfo);
}
else
{
__cmp('cancelwait'); //tell the CMP to no longer wait for import calls
}
__cmp('addEventListener', ['consent', storeConsent, false], null);
</script>
Example of Cross-Domain Consent Shareing on click
Cross-Domain Consent Sharing is becoming more complicated due to the the deprecation of third party cookies. A way around this issue can be to send consent data via the URL instead of sharing a cookie. In order to do this automatically, you can use the following script on your website:
<script>
window.cmp_allowedDomains = [];
//window.cmp_allowedDomains.push('*'); // use this line to append consent data to all urls ...
window.cmp_allowedDomains.push('mywebsite.com'); // ... or add your domains here ...
window.cmp_allowedDomains.push('myotherwebsite.com');
window.cmp_allowedDomains.push('mythirdwebsite.com');
window.cmp_appendclick = function (evt)
{
try
{
evt = evt || window.event;
if (evt.target && evt.target.nodeName && evt.target.nodeName.toUpperCase() === 'A' && evt.target.hostname && evt.target.hostname != '' && evt.target.hostname != location.hostname)
{
var found = false;
var hn = evt.target.hostname.toLowerCase();
for (var i = 0; i < window.cmp_allowedDomains.length; i++)
{
var d = window.cmp_allowedDomains[i].toLowerCase();
var a = ('.' + hn).substr(hn.length - d.length, 9999);
if (window.cmp_allowedDomains[i] == '*' || a == '.' + d)
{
found = true;
break;
}
}
if (found)
{
if ('hash' in evt.target && evt.target.hash == '')
{
evt.target.hash = '#' + __cmp('exportConsent');
}
}
}
}
catch (e)
{}
};
window.addEventListener('mousedown', window.cmp_appendclick);
</script>
App
For apps the procedure is the same as for web, only the functions/names are different.
Android
In order to export the consent information, please use
String consentData = CMPConsentTool.exportCMPData(this);
In order to import the consent information, please use
CMPConsentTool.importCMPData(this, "...data...");
iOS
In order to import/export the consent information, please use (https://help.consentmanager.net/books/cmp/page/consentmanager-sdk-for-ios#bkmrk-import%2Fexport-consen)
// Instanstiate CMPConsentTool()
cmpConsentTool = CMPConsentTool.init(...)
// Importing consent data if you like
cmpConsentTool.importCMPData("${your consentString}");
// ... Your code here ...
// Exporting Consent data
let consentString : String = CMPConsentTool.exportCMPData()