Cookiebot

Connect Shoplift with Cookiebot to ensure A/B testing respects visitor privacy preferences and maintains compliance with GDPR and other privacy regulations.

Overview

Cookiebot provides automatic cookie discovery and classification, helping businesses maintain GDPR compliance. This guide demonstrates how to sync Cookiebot's consent management with Shoplift's analytics tracking.

Prerequisites

  • Cookiebot implemented on your Shopify store

  • Cookiebot script ID (CBID) from your Cookiebot account

  • Statistics/Analytics category configured in Cookiebot

Implementation

Basic Integration

Add this code after your Cookiebot script:

// 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?