Usercentrics - PUBLIC

How to communicate consent information for services integrated via third-party system like segment.io?

In this guide we will show you how to communicate consent from the Usercentrics CMP to third party systems like segment.io. This is needed when you have further technologies like Google Analytics implemented via a system like segment.io, which are only allowed to fire on your website once consent is given by the end user in the Usercentrics CMP.

In general this can be done by using a window event (CMP v2 | CMP v1) and pushing the consent information into the third party system every time the event gets triggered.
For the CMP v2 this event gets triggered in two occasions:

  • After the app initialized with the default consent status or the current consent status

  • After saving any new consent change

As segment.io already provides an out of the box method for passing such information to their system, we will have a look at it in detail in the setup guide below. For other systems, the way of transferring the consent may differ, but the basic approach remains the same.

Setup Guide

We suggest the following steps to communicate the consent information by the Usercentrics CMP for all services integrated via Segment.io using a window event.

  • Set up Segment.io and all services like Google Analytics (which are integrated via Segment.io) as individual Services in the CMP configuration (Admin Interface / Service Settings / Data Processing Services).

  • Add a window event in the Admin Interface (e.g. "ucEvent") under Implementation / Data Layer and Events

     

  • Use this window event to check existing consent & user consent decisions and then pass this consent information to segment.io using their .load method.
    As mentioned above, more Information on the Usercentrics events and event listeners can be found in our technical documentation: (CMP v2 | CMP v1)

Example for segment.io

In the following you find a sample script for the communication of the Google Analytics Consent Information to Segment.io.

<script> var segment_already_loaded = false; window.addEventListener('ucEvent', function (event) { var consent_segment = false; var consent_googleanalytics = false; //check if consent for Google Analytics is given if(event.detail.hasOwnProperty('Google Analytics') && event.detail['Google Analytics'] === true) { consent_googleanalytics = true; } // check if consent for segment.io is given if(event.detail.hasOwnProperty('Segment.io') && event.detail['Segment.io'] === true) { consent_segment = true; } // if you don't want to call segment without consent, you can put the call in the if case where it checks the consent for it // check if segment was already loaded on this page impression (assuming it should only be done once. Hint: The event may be triggered multiple times if the user gets/opens the cmp and makes/changes his decisions) if(window.segment_already_loaded !== true) { // call segment load with consent information analytics.load('YOURKEY', { integrations: { All: false, 'Google Analytics': consent_googleanalytics, 'Segment.io': consent_segment } }) window.segment_already_loaded = true; } else { } }); </script>



 

Usercentrics - PUBLIC