Adding custom events is only available for versions 2 and up, for Business, Enterprise, and Advanced & Premium Add-On packages.
In order to use a custom event that is fired when consent is given or updated, you need to create a new Window Event.
You may find this under the Implementation section, on the Data Layer & Events tab.
Click the + icon to add a new window event and specify the name of the event in the field labeled Window Event Name.
In this example we'll use "ucEvent".
To execute a script only after a user gives their consent for a specific service, you'll need to check if consent indeed was given for this service.
Hee is an example of how you could implement this:
<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>
Comments
0 comments
Please sign in to leave a comment.