Shopify Customer Privacy
Pass consent to Shopify's Customer Privacy API so its own tracking respects it.
Last updated:
What it does. Calls Shopify's Customer Privacy API so Shopify's built-in tracking, and any app that reads consent through it, sees the visitor's choice.
Consent category. analytics and marketing.
How it works
Shopify takes all three flags in one call:
window.Shopify.customerPrivacy.setTrackingConsent({
analytics: true,
marketing: true,
preferences: true
}, callback);
The bridge fills them from the resolved consent state on each update. analytics comes from analyticsStorage and marketing from adStorage.
One thing to know before you rely on it: preferences is currently set from the analytics value, not from a preferences category. If you use Shopify's preferences flag to gate anything meaningful, check that it's behaving the way you expect, because a visitor who accepts analytics and declines preferences will still be reported to Shopify as having allowed preferences.
Setup
On by default. Toggle it under Vendor Consent Signals on the banner's App Integrations page, then publish.
The API has to be on the page for the call to land. The bridge calls it when consent resolves, and if Shopify hasn't loaded its Customer Privacy script yet, that call is dropped. The CookieBeam app below loads the API itself and replays the choice once it's ready, so use the app rather than pasting the script tag into the theme.
Install with the CookieBeam app
The CookieBeam Shopify app is a theme app embed. There is nothing to paste into theme code, and it survives theme updates. When you switch themes, verify that the app embed is still activated in the new theme's settings. The embed targets the compliance_head block, which Shopify renders inside <head> after content_for_header; theme scripts that load before content_for_header may run before it. For stricter ordering, see App embed ordering. Use one loader installation per page, not both.
- In CookieBeam, add the store's domains to the banner: the
*.myshopify.comdomain and any custom domain. - Install the CookieBeam app on the store.
- Go to Online Store → Themes → Customize → App embeds and turn on CookieBeam consent banner.
- Paste the banner ID from Deployment → Install in the dashboard (the UUID in the script URL). Leave Environment empty for production. Save.
- In Shopify admin, go to Settings → Customer privacy and turn off Shopify's own cookie banner, so visitors don't see two.
- Publish the banner in CookieBeam.
The embed does two things:
- It loads the banner in
<head>from the same URL as the install snippet. The embed uses Shopify'scompliance_headplacement, which Shopify includes first among app embeds and intends for cookie consent banners. Shopify doesn't say this puts it ahead of{{ content_for_header }}or your theme's own head scripts. If you need the banner to load before everything else, also follow Install on Shopify and put the loader on the first line oftheme.liquid. - With Sync consent with Shopify Customer Privacy on (the default), it loads Shopify's Customer Privacy API with
Shopify.loadFeatures([{ name: 'consent-tracking-api', version: '0.2' }])and passes every choice tosetTrackingConsent. It also setssale_of_datafrom the marketing value, in a separate call as Shopify recommends, which the bridge doesn't send. That way Shopify's opt-out of sale is honoured for US visitors.
If the bridge is also on, Shopify receives the same answer twice, which does no harm.
Theme app extensions don't run on checkout pages, so the banner doesn't appear at checkout. The choice made on the storefront is stored by Shopify's Customer Privacy API and carries over.
Testing
Read the current state back from Shopify:
window.Shopify.customerPrivacy.currentVisitorConsent()
Make a choice in the banner and call it again. The returned flags should match what you chose, allowing for the preferences behaviour above.