Usercentrics - PUBLIC

Shopify Consent Tracking API

We always recommend our Customers to use the Google Analytics Script in the head section of Source-code of their website and they should adjust the third-party Scripts according to Usercentrics. This is the right recommended way to implement Google Analytics for Shopify Store. In this case, if users have provided consent for GA Service via CMP Banner, then only Script for GA will be executed. Please find below the link to Usercentrics Shopify Integration Guide for CMP V2.

Usercentrics Shopify Implementation Guide (CMP v2)

However, Customers can use the Google Analytics section option and other options for Facebook Pixel section provided by Shopify too, but this is complex way to implement these Services. For this, customers need to use Shopify Consent API (to avoid execution all the time but only if Consent API has gotten permission).

The code should be implemented in your Theme Shopify Shop → Theme → Customize → Custom head Javascript.

These steps need to be followed:

  1. Load our (browser UI) CMP Script Tag (you should create a Data Processing Service 'All My Shopify Trackings' for your SettingsID before [Shopify only takes a non-granular yes or no in their consent api (see Customer Privacy API ) and therefore you need to rely on one service] additionally you create a window event ucEvents to listen for)

  2. line 2-15 loads the Shopify consent api feature

  3. line 17 create a dummy callback function as shopify-consent-api needs one

  4. line 18-31: liste for ucEvents and based on status of consent for 'All My Shopify Trackings' send yes / no to the Shopify Consent API.

<script id="usercentrics-cmp" data-settings-id="XXXXXXXXX" src="https://app.usercentrics.eu/browser-ui/latest/bundle.js" defer=""></script> <script type="text/javascript"> window.Shopify.loadFeatures( [ { name: 'consent-tracking-api', version: '0.1' } ], function(error){ if(error) throw error // Initialize cookie banner console.log('feature loaded'); } ); var ucConsentCallback = function() {console.log('consent submitted to shopify')}; window.addEventListener("ucEvents", function (e) { if( e.detail && e.detail.event == "consent_status") { // check for consent status of service "All My Shopify Trackings" if(e.detail['All My Shopify Trackings'] === true) { console.log('All My Shopify Trackings has consent'); window.Shopify.customerPrivacy.setTrackingConsent(true,ucConsentCallback); } else { console.log('All My Shopify Trackings has no consent'); window.Shopify.customerPrivacy.setTrackingConsent(false,ucConsentCallback); } } }); </script>

The important points are that there is no plugin needed, but Shopify consent API only supports non-granular consent. This might be a problem from the compliance perspective. The non-granularity of Shopify is however something that customers have to keep in mind and discuss with their data protection officer.

Usercentrics - PUBLIC