/
Shopify Sync With Usercentrics CMP V3

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/ 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).

Screenshot 2024-08-09 at 23.33.29.png
  • 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)

Screenshot 2024-08-09 at 23.44.56.png

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 2 - 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:

Screenshot 2024-08-10 at 00.57.25.png

 

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"

Screenshot 2024-08-10 at 01.02.07.png
  • 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.

Screenshot 2024-08-10 at 01.03.00.png

Related content

Usercentrics - PUBLIC