I tried to implement the Privacy API with our consent management platform.
I followed the documentation and created a script to update consent based on users interactions on our cookie widget, using this documentation : https://shopify.dev/docs/api/consent-tracking
A few things could cause this issue where the object “Shopify.customerPrivacy” is undefined on the website:
The Customer Privacy API is not loaded properly: Ensure that you have correctly loaded the Customer Privacy API. You can do this by invoking the Shopify.loadFeatures function as described in the documentation.
The script is executing before the API has finished loading: It’s important to remember that the API load is asynchronous. If your script is running before the API has fully loaded, Shopify.customerPrivacy could be undefined. Ensure that your code is wrapped inside the callback of loadFeatures or is running after the API has loaded.
Conflicts with other scripts: If you have other JavaScript running on your site, there could be conflicts that are causing issues with the Customer Privacy API. You might want to check and debug any other scripts you have running.
The website is using a cached version of the page: Clear the cache and cookies of your browser and try again.
Try out the above and let us know if you’re still experiencing issues,
What about on checkout where Shopify.loadFeatures is not defined? I currently have to parse the _tracking_consent cookie which really screws up the whole idea of having a Javascript API.