Skip to main content

Customer Privacy API

Requires access to protected customer data. The region property requires level 1 access. The applyTrackingConsentChange property requires the collect_buyer_consent capability.

The Customer Privacy API provides access to the buyer's tracking consent preferences and lets your extension apply consent changes. Use this API to build consent banners, check current consent decisions for analytics, marketing, and data sale, and save updated preferences.

  • Display a consent banner: Determine whether to show a cookie consent banner when the page loads.
  • Read current consent state: Check the buyer's current preferences for analytics, marketing, and data sharing.
  • Apply consent changes: Save the buyer's updated consent preferences after they interact with your consent UI.
  • Handle regional requirements: Detect if the buyer is in a jurisdiction requiring specific opt-out controls, such as CCPA in California.
Support
Targets (24)

The shopify global object provides the customer privacy data and consent management methods. Access the following properties on shopify to read privacy consent settings and apply consent changes.

Anchor to applyTrackingConsentChange
applyTrackingConsentChange
required

Applies updated tracking consent preferences for the buyer, including their decisions for analytics, marketing, and data sale, along with any custom tracking consent metafields. Returns a promise that resolves with the result of the consent update.

Requires the collect_buyer_consent capability and access to protected customer data.

Anchor to customerPrivacy
customerPrivacy
<>
required

The buyer's current privacy consent settings, including their consent decisions for analytics, marketing, and data sale, whether a consent banner should be displayed, and whether the buyer is in a region that requires specific opt-out controls. Use this to read the buyer's consent state and determine how to display privacy-related UI.


  • Use shouldShowBanner for initial state: Check the shouldShowBanner property to determine whether to display a consent banner when the page loads, rather than always showing one.
  • Respect regional requirements: Use saleOfDataRegion and region to determine if additional opt-out controls are required for the buyer's location.

Was this page helpful?