customerPrivacy.setTrackingConsent() always returning success and true despite sending false?

Hello,

We’re trying to troubleshoot some issues in connecting our OneTrust implementation, GTM and Shopify Privacy API.

The pattern we’re using seems to work quite well, except for the calls to setTrackingConsent, which seemingly ignore instructions.

      window.Shopify.customerPrivacy.setTrackingConsent(
        {
          marketing: false,
          analytics: false,
          preferences: false,
          sale_of_data: false,
        },
        (data) => {
          if (data?.error) {
            console.error('Error setting tracking consent:', data.error);
            return;
          }
          console.log('Tracking consent set');
        },
      );

Which returns:
Consent event received, updating true {marketing: ‘yes’, analytics: ‘yes’, preferences: ‘yes’, sale_of_data: ‘no’}

followed by:

window.Shopify.customerPrivacy.currentVisitorConsent();

Which returns:
{marketing: 'yes', analytics: 'yes', preferences: 'yes', sale_of_data: 'no'}

In code, this is wrapped inside of the callback for OneTrust consent, but that doesn’t seem relevant considering you can reproduce the problem direct from your console using the above scripts.

I’ve tried this on many of our managed sites as well as some other random shopify (headed) sites and it’s the same situation everywhere I go. What could be preventing a proper update when:

  • No VPN
  • GPC flag is not enabled
  • The call is “successful”

I’ve also now verified I can look up the consent ID in the consent logs in Shopify and they show as Consent Rejected. Yet the window.Shopify.customerPrivacy.currentVisitorConsent(); still returns a result showing that all consent was given.

I was having this exact issue and figured it out.

Its all to do with the customer privacy section in shopify admin. You need to ensure the cookie banner is fully disabled, as you do not want any of the shopify defaults happening as that is what is setting the values to true.

Thanks for responding @John_Mitchell What exactly do you mean “Fully disabled”? It doesn’t look like it’s ever been enabled and currently doesn’t appear to be enabled, but maybe I’m missing something. Can you point to a specific setting or is it something in theme code that enables it beyond the settings in the privacy and cookie banner area?