Solved

Privacy API and external CMP

loicAxeptio
Shopify Partner
1 0 0

Hello, 

 

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

It worked fine on several websites, but it won't work on this website : https://www.blue-cult.com/

Even if I select the option "Collected after consent" in the preferences, the object "Shopify.customerPrivacy" is undefined.

I put it back on "Collected before consent" for now to prevent data loss.

 

Did I miss something ?

 

Best regards

Accepted Solution (1)

Liam
Shopify Staff
2731 302 777

This is an accepted solution.

HI LoicAxeptio,

A few things could cause this issue where the object "Shopify.customerPrivacy" is undefined on the website:

  1. 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.

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

  3. 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.

  4. 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, 

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Reply 1 (1)

Liam
Shopify Staff
2731 302 777

This is an accepted solution.

HI LoicAxeptio,

A few things could cause this issue where the object "Shopify.customerPrivacy" is undefined on the website:

  1. 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.

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

  3. 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.

  4. 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, 

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog