What Is the Shopify Customer Privacy API?

Shopify's Customer Privacy API is an essential tool for app developers and store owners aiming to comply with global data privacy laws like the GDPR, CCPA, and other regional regulations. This API provides structured methods to collect, store, and manage customer consent regarding the use of their personal data, ensuring transparency and security across your store or app.

How It Works

A Consent Management Platform (CMP) uses the Customer Privacy API to track when and how a user grants or withdraws consent. This consent data is then made available to apps and custom code, allowing them to adjust behavior in real-time—for example, disabling tracking if the user declines consent.

Example Usage

The following JavaScript snippet shows how to load the Customer Privacy API and retrieve the current visitor's consent status:

window.Shopify.loadFeatures(
  [
    {
      name: 'consent-tracking-api',
      version: '0.1',
    },
  ],
  (error) => {
    if (error) {
      // Handle loading error
      return;
    }

    // API is ready—check visitor consent
    const consent = window.Shopify.customerPrivacy.currentVisitorConsent();
    console.log(consent); // Outputs consent categories and their status
  }
);

The API returns consent status for the following categories:

  • analytics
  • marketing
  • preferences
  • sale_of_data

Each category will return 'yes' or 'no', allowing you to conditionally load or block third-party scripts based on user preferences.

essential is always enabled by Shopify and cannot be toggled.