Skip to main content

Customer Privacy API

Requires access to protected customer data for some properties.

The Customer Privacy API provides access to the buyer's privacy consent preferences during checkout. Use this API to check consent status for analytics and marketing, and display appropriate consent notices. It's similar to the Customer Privacy API in storefront.

Applying tracking consent changes requires the customer_privacy capability to be enabled in your extension configuration.

  • Check consent status: Determine whether the buyer has responded to analytics and marketing consent prompts.
  • Display a consent banner: Show a cookie preferences banner when consent hasn't been provided yet.
  • Respect privacy preferences: Conditionally render features based on the buyer's consent choices.
Support
Targets (31)

Anchor to Properties and methodsProperties and methods

The shopify global object provides customer privacy data and consent management. Access the following on shopify to read consent preferences and apply tracking consent changes. Available to purchase extension targets.

Anchor to applyTrackingConsentChange
applyTrackingConsentChange
required

Enables setting and updating customer privacy consent settings and tracking consent metafields.

Note

Requires the collect_buyer_consent capability to be set to true.

Requires access to protected customer data.

Anchor to customerPrivacy
customerPrivacy
<>
required

Customer privacy consent settings and a flag denoting if consent has previously been collected.


  • Use shouldShowBanner as the initial banner state: This property considers the visitor's current consent, the shop's region visibility settings, and the visitor's location. Use it instead of building custom logic to determine when to show a consent banner.
  • Distinguish between false and undefined in consent values: A false value in visitorConsent means the buyer explicitly declined consent. An undefined value means they haven't responded yet. Handle these states differently in your extension.

Was this page helpful?