OneTrust
Overview
Prerequisites
Implementation
Basic Integration
// OneTrust + Shoplift Consent Integration
(function() {
// Function to sync OneTrust consent with Shoplift
function syncOneTrustWithShoplift() {
if (!window.OnetrustActiveGroups) {
// OneTrust not ready yet
setTimeout(syncOneTrustWithShoplift, 100);
return;
}
// Check if performance/analytics cookies are accepted
// C0002 is typically Performance Cookies - verify your OneTrust configuration
const hasAnalyticsConsent = window.OnetrustActiveGroups.includes('C0002');
// Update Shoplift consent
if (window.shoplift && window.shoplift.setAnalyticsConsent) {
window.shoplift.setAnalyticsConsent(hasAnalyticsConsent)
.then(() => {
console.log('Shoplift consent synchronized with OneTrust:', hasAnalyticsConsent);
})
.catch(error => {
console.error('Failed to update Shoplift consent:', error);
});
} else {
// Retry if Shoplift isn't ready
setTimeout(syncOneTrustWithShoplift, 100);
}
}
// Initial sync on page load
syncOneTrustWithShoplift();
// Listen for consent changes
window.OneTrust.OnConsentChanged(function() {
syncOneTrustWithShoplift();
});
})();Advanced Integration with Cookie Categories
OneTrust Configuration
Finding Your Category IDs
Testing Your Integration
Debug Console Commands
Testing Consent Scenarios
Last updated
Was this helpful?