In this guide we will show you how to communicate consent from the Usercentrics CMP to a third party system. This could be needed when you have technologies implemented via a system like a tag manager. These systems should only load services on your website once consent is given by the end user using the Usercentrics CMP consent banner.
Please note
This guide applies to Usercentrics v3. We recommend migrating to the latest version if you're still using a previous version.
A consent event gets triggered on two occasions:
-
After the app initialized with the default- or current consent status.
-
After submitting or changing consent.
For each systems the method of transferring data to it may differ, but the basic approach remains the same.
Setup Guide
Take the following steps to enable communication of consent information by Usercentrics CMP using a window event.
-
Set up the system that loads services as well as these services themselves as individual services in the CMP configuration.
You can do this on the Data Processing Services tab, in the Service Settings section.
In the image below the system loading services is Google Tag Manager, the service that is loaded through it is Google Analytics 4. - Add a window event in the Admin Interface (for example "ucConsentEvent").
You can do this under Implementation in the Data Layer & Events tab - Use this window event to establish the consent choices and to then pass this information to a third-party application.
Example
This is an example of how you can listen for a consent event to determine whether a service should be allowed to load.
<script>
window.addEventListener("{{Event name}}", function (event) {
const services = event.detail.services;
for (let i in services) {
var service = services[i];
if (service.name == "{{Name of the DPS}}" && service.consent.given) {
// Do something if consent was given for the Data Processing Service
}
}
});
</script>
Important
Remember to replace {{Event name}}
with the name of the event you've added to the Admin and replace {{Name of the DPS}}
with the name of the service you want to check whether it has been given consent for.
Comments
0 comments
Please sign in to leave a comment.