Usercentrics CMP Testing

Test different Usercentrics CMP (Consent Management Platform) banner variants using ABlyft.

On this page

Important Dependencies

  • The ABlyft script must be placed in the <head> of the page and must load before Usercentrics.
  • The definition and design of the variants is done via the Usercentrics platform.

In ABlyft

Experiment and Variants

  1. Create an experiment.
  2. Create a variant of type "Code".
  3. In Variant 1, add the following code:
window.UC_AB_VARIANT = "variant1";
  1. In the Original variant, add the following code:
window.UC_AB_VARIANT = "variant0";

Goals

Usercentrics provides measurement of various events. Here is a list of available events:

Event Name Description
CMP_SHOWN Event triggered when the CMP is shown
ACCEPT_ALL Event triggered by clicking the Accept All button
DENY_ALL Event triggered by clicking the Deny All button
SAVE Event triggered by clicking the Save button
MORE_INFORMATION_LINK Event triggered by clicking the More Information button
IMPRINT_LINK Event triggered by clicking the Imprint link
PRIVACY_POLICY_LINK Event triggered by clicking the Privacy Policy link

To use these events as goals in ABlyft, the following steps are required:

Goal Creation

Create as many goals as needed of type "Custom".
The API name is important. Example: usercentrics_ACCEPT_ALL (i.e. usercentrics_ followed by the Event Name from the list above).

Event Handling in Project JavaScript

Add the following code to the project settings under Project JavaScript:

window.addEventListener('UC_UI_CMP_EVENT', function (data) {
    window['ablyft'] = window['ablyft'] || [];
    window['ablyft'].push({
        eventType: 'custom',
        eventName: 'usercentrics_' + data.detail.type,
    });
});