Cookiebot
Overview
Prerequisites
Implementation
Basic Integration
// Cookiebot + Shoplift Consent Integration
(function() {
// Function to sync Cookiebot consent with Shoplift
function syncCookiebotWithShoplift() {
// Check if Cookiebot is loaded
if (typeof Cookiebot === 'undefined') {
setTimeout(syncCookiebotWithShoplift, 100);
return;
}
// Check for statistics/analytics consent
const hasAnalyticsConsent = Cookiebot.consent && Cookiebot.consent.statistics;
// Update Shoplift consent
if (window.shoplift && window.shoplift.setAnalyticsConsent) {
window.shoplift.setAnalyticsConsent(hasAnalyticsConsent)
.then(() => {
console.log('Shoplift consent synchronized with Cookiebot:', hasAnalyticsConsent);
})
.catch(error => {
console.error('Failed to update Shoplift consent:', error);
});
} else {
// Retry if Shoplift isn't ready
setTimeout(syncCookiebotWithShoplift, 100);
}
}
// Listen for Cookiebot consent events
window.addEventListener('CookiebotOnAccept', syncCookiebotWithShoplift);
window.addEventListener('CookiebotOnDecline', syncCookiebotWithShoplift);
window.addEventListener('CookiebotOnLoad', syncCookiebotWithShoplift);
// Initial sync
syncCookiebotWithShoplift();
})();Last updated
Was this helpful?