Usercentrics - PUBLIC
How can I use an event listener? (V2)
he function Window Event Name is available for Business and Enterprise packages as well as Advanced & Premium Add-On.
In order to use a custom event listener, you need to create a Window Event Name. The window event name can be configured under:
Implementation → Data Layer and Events → Window Event Name
You can specify any name as the event name, for example ucEvent
.
Â
To run a script after a user gives his/her consent for a specific service, you need to check if consent has given to this service.
To do so, please follow the script below:
<script>
window.addEventListener("ucEvent", function (e) {
if( e.detail && e.detail.event == "consent_status") {
if(e.detail['Google Ads Remarketing'] === true) { // check for consent status of service "Google Ads Remarketing"
console.log('Google Ads Remarketing has consent'); // add your script here
} else {
console.log('Google Ads Remarketing has no consent'); // add your script here
}
}
});
</script>
Do you need further help?
How can I get help with technical questions?
Â
Usercentrics - PUBLIC