OneTrust's CookiePro product provides a way to manage users' cookie preferences, and ensure GDPR cookie compliance.
Littledata has written a script to integrate OneTrust with Shopify's Customer Privacy API. This makes OneTrust compatible with Shopify's own tracking, and Littledata's enhanced tracking scripts.
<!-- OneTrust to Shopify Customer Privacy API integration by Littledata --><script src="https://master-shopify-tracker.s3.amazonaws.com/oneTrust.js"/>
After the CookiePro script loads, this script registers a callback function to be triggered when the user updates their preferences.
When that update happens, if the user has consented to 'Cookies for performance' (tracked as category C0002
in OneTrust's consent preferences), the userCanBeTracked()
field is set to true
and Shopify and Littledata's tracking then starts. This will also work with any other apps which integrate with Shopify's Customer Privacy API.
If the user later revokes consent to Cookies for performance , then userCanBeTracked()
is set to false
.
Here's an example of OneTrust setup with Age UK.
When the user clicks "Accept all Cookies", then userCanBeTracked()
is set to true
.
Then, if the user opts out of "Cookies for performance," the tracking stops.
Here is the full source code.
OneTrust also offers the ability to auto-block common tracking scripts, such as Google Analytics, based on categorizing the third party scripts.
The advantage of using this integration is that it will work seamlessly with any other apps working with Shopify's customer privacy API - so it plays nicely with Shopify's app ecosystem.