Activate Code Elements with Consent
const VENDOR_ID = "adobeanalytics";
function executeMyCode() {
/*
*Your custom code here.
*/
}
// DO NOT CHANGE:
var eventTarget;
if (
typeof window.jentis !== "undefined" &&
window.jentis.consent &&
window.jentis.consent.engine
) {
// SDK already loaded, so listen on the consent engine directly.
eventTarget = window.jentis.consent.engine;
} else {
// SDK not loaded yet, so listen on document for the init event.
eventTarget = document;
}
function onVendorChange(event) {
var consentStatus = event.detail && event.detail[VENDOR_ID];
if (consentStatus === true) {
executeMyCode();
}
}
function onConsentInit() {
var engine = window.jentis && window.jentis.consent && window.jentis.consent.engine;
var vendorConsent;
if (!engine) {
return;
}
vendorConsent = engine.getVendorConsent(VENDOR_ID);
if (vendorConsent === true) {
executeMyCode();
} else {
engine.addEventListener("jentis.consent.engine.vendor-change", onVendorChange);
}
}
eventTarget.addEventListener("jentis.consent.engine.init", onConsentInit);
Last updated
Was this helpful?