The UC_UI_CMP_EVENT event is triggered by the most important actions that can be performed in the CMP, enabling you to listen to user interactions.
UC_UI_CMP_EVENT is a CustomEvent dispatched on the window object.
This event might prove useful when trying to compare the different variants when using the A/B Testing feature.
The structure of the detail (event.detail) is the following:
{
abTestVariant: undefined,
source: "second",
type: "CMP_SHOWN"
}abTestVariant
String that identifies the A/B test variant currently in use, if none, the value will be undefined.
Its value matches the variant key defined in the A/B Testing JSON configuration in the Admin Interface. For a standard two-variant setup, the possible values are:
Value | Description |
|---|---|
"variant0" | The first configured A/B Testing variant |
"variant1" | The second configured A/B Testing variant |
Additional variants can be configured with their own custom keys, in which case abTestVariant will match the configured key instead.
source
Where the event was triggered, it can be:
Source | Description |
|---|---|
"none" | Triggered when the CMP was not being shown |
"button" | Triggered when the Privacy Button was being shown |
"first" | Triggered when the First Layer was being shown |
"second" | Triggered when the Second Layer was being shown |
"embeddings" | Triggers when the Embeddings were being shown |
"__ucCmp" | Triggered by the |
type
Event Name | Description |
|---|---|
CMP_SHOWN | Triggered when the CMP is shown |
ACCEPT_ALL | Triggered by clicking the Accept All button |
DENY_ALL | Triggered by clicking the Deny All button |
SAVE | Triggered by clicking the Save button |
MORE_INFORMATION_LINK | Triggered by clicking the More Information button |
IMPRINT_LINK | Triggered by clicking the Imprint link |
PRIVACY_POLICY_LINK | Triggered by clicking the Privacy Policy link |
Example
window.addEventListener('UC_UI_CMP_EVENT', function(event) {
console.log('UC_UI_CMP_EVENT event detail', event.detail)
});