Usercentrics - PUBLIC
Shopify Sync With Usercentrics CMP V3
Instructions for CMP v3
Step 1 - update your list of DPS
Access the Usercentrics Admin Interface for your CMP configuration or SettingID. Locate and remove the 'All My Shopify Trackings' cDPS (or any other similarly broad DPS related to Shopify Tracking that you may have set up).
Add three new predefined Data Processing Services:
āShopify Analyticsā (Template ID: ZQOx-TM97Y3rLe)
āShopify Marketingā (Template ID: zixK7I8y1mhf1D)
āShopify Preferencesā (Template ID: T4PQQdTkrEofhd)
note: it should have the exact same name as listed above)
Donāt forget to save your changes with the Save Draft or Publish buttons from the left sidebar. More details about this in our Preview & Publish feature tech doc.
Details about window event usage.
Step 3 - replace the existing consent tracking script with the new one, or add the new script if none currently exists.
Navigate to your Shopify layout and open the
theme.liquid
file.Locate the Shopify Consent Tracking API script within your HTML. You can refer to this old documentation to confirm you've identified the correct script.
Remove the old script and replace it with the new script provided below, placing it at the bottom of your
<head>
section.
<script type="text/javascript">
window.Shopify.loadFeatures(
[{ name: 'consent-tracking-api', version: '0.1' }],
error => {
if (error) throw error
console.log('** Shopify Consent Tracking API loaded');
const syncTrackingConsent = consentObj => {
window.Shopify.customerPrivacy.setTrackingConsent(consentObj, () => {
console.log("** UC consent synced with Shopify Customer Privacy API")
console.log("- Shopify consent:")
console.log(window.Shopify.customerPrivacy.currentVisitorConsent())
console.log("--------------------------")
})
}
window.addEventListener("UC_CONSENT", e => {
const services = Object.values(e.detail.services)
const ucAnalytics = services.find(service => service.name == 'Shopify Analytics')
const ucMarketing = services.find(service => service.name == 'Shopify Marketing')
const ucPreferences = services.find(service => service.name == 'Shopify Preferences')
if (ucAnalytics && ucMarketing && ucPreferences) {
const analyticsConsent = ucAnalytics.consent.given
const marketingConsent = ucMarketing.consent.given
const preferencesConsent = ucPreferences.consent.given
console.log('** Usercentrics consent:')
console.log("- status: " + e.detail.consent.status)
console.log("- updatedBy: " + e.detail.consent.updatedBy)
console.log("- Analytics: " + analyticsConsent)
console.log("- Marketing: " + marketingConsent)
console.log("- Preferences: " + preferencesConsent)
const isOptOut = window.Shopify.customerPrivacy.saleOfDataRegion()
console.log("** is using Opt-Out framework: " + isOptOut)
if (isOptOut) {
const val = e.detail.consent.status == 'ALL_DENIED' ? false : true
syncTrackingConsent({
analytics: val,
marketing: val,
preferences: val,
sale_of_data: val
})
} else {
syncTrackingConsent({
analytics: analyticsConsent,
marketing: marketingConsent,
preferences: preferencesConsent,
})
}
} else {
throw 'No DPSs found (Shopify Analytics, Shopify Marketing, Shopify Preferences)'
}
})
}
)
</script>
This is what your file will look like:
Ā
Step 3 - ensure the script is working
Visit your Shopify store's website and open the Developer Tools console.
Confirm that you see the log message: "** Shopify Consent Tracking API loaded"
Open the Usercentrics banner and modify your consent preferences.
Verify that the console displays the log: "** UC consent synced with Shopify Customer Privacy API," along with the consent details, ensuring it is properly synced.
Usercentrics - PUBLIC