Customer Privacy API

The customer privacy API is a browser-based, JavaScript API that enables developers to read and write cookies related to a buyer's consent to be tracked. The API is implemented as a property on the global window.Shopify object and is accessible to all Shopify online stores.

You can use the API to build consent collection mechanisms such as banners for General Data Protection Regulation (GDPR) compliance. For marketing and analytics use cases, you can use the API when tracking or exporting data about storefront visitors to cover both GDPR compliance and accordance with the California Consumer Privacy Act (CCPA).

What you'll learn

You can use the following methods for consent collection:

If the API fails to load, then the banner won't initialize.

To initialize the Customer Privacy API, you need to use the loadFeatures method and initialize your banner in the callback function.

shouldShowGDPRBanner(): boolean

You can use this method to determine if you should show a GDPR banner.

Request data



This method returns a boolean value that indicates if you should show a GDPR banner to the visitor.

The response aggregates the visitor’s location, the merchant’s preference, and whether the visitor has already provided a consent value in the past year.

Visitor consent provided in past year Visitor in EU Merchant limits tracking for customers in Europe Boolean value
Not applicable Not applicable false

You can use this method to set a buyer's response to a tracking consent request.

Request data