Skip to main content

Customer Privacy
API

Requires access to protected customer data for some properties.

The API for interacting with a customer's privacy consent. It is similar to the Customer Privacy API in storefront.

The base API object provided to this and other customer-account extension targets.

Anchor to applyTrackingConsentChange
applyTrackingConsentChange
required

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

Note

Requires the customer_privacy capability to be set to true.

Requires access to protected customer data.

<>
required

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

Was this section helpful?

Read Customer Privacy

Preact

import '@shopify/ui-extensions/preact';
import {render} from 'preact';

export default async () => {
render(<Extension />, document.body);
};

function Extension() {
const visitorConsent =
shopify.customerPrivacy.value
.visitorConsent || {};

// Use consent values
console.log(
'analytics',
visitorConsent.analytics,
);
console.log(
'marketing',
visitorConsent.marketing,
);
console.log(
'preferences',
visitorConsent.preferences,
);
console.log(
'saleOfData',
visitorConsent.saleOfData,
);

return null;
}