Platform guides
Cookie consent on Shopify: setup guide
Shopify has a built-in cookie banner and a Customer Privacy API that its own cookies, pixels and checkout respect. Whatever banner you use, it has to report visitors' choices to that API, or Shopify's tracking and your own scripts won't follow them.
- Plain English
- Written for website owners
- Free to read
On this page
- How consent works on Shopify
- Option 1: Shopify's built-in cookie banner
- Option 2: a consent app from the App Store
- Option 3: your own banner in theme.liquid
- Blocking scripts hardcoded in your theme
- Google, Meta and other sales channel apps
- Testing your Shopify consent setup
- Next steps
- Frequently asked questions
To set up cookie consent on Shopify, choose one of three routes: turn on Shopify's built-in banner under Settings → Customer privacy, install a consent app from the Shopify App Store, or add an external consent banner to theme.liquid and pass its choices to Shopify's Customer Privacy API. Whichever you pick, two things must be true: Shopify receives the visitor's choice, and any scripts you added to the theme yourself wait for consent.
Menu names in the Shopify admin change from time to time, so the paths below may differ slightly in your store.
How consent works on Shopify
Shopify stores each visitor's consent through its Customer Privacy API, a JavaScript API available on Online Store pages at window.Shopify.customerPrivacy. It tracks four purposes:
| API purpose | Covers |
|---|---|
analytics | Measurement, including Shopify's own analytics |
marketing | Advertising and retargeting pixels |
preferences | Remembered settings and personalization |
sale_of_data | Opt-out of sale or sharing under US state laws |
Shopify applies the stored choice to the surfaces it controls: its own cookies, pixels you manage under Settings → Customer events (both app pixels and custom pixels), and checkout. Outside the regions where you require consent, Shopify treats these purposes as allowed by default. Inside them, non-essential purposes stay off until the visitor agrees. Shopify's documentation also says it honors the Global Privacy Control signal for sale of data automatically in configured regions. See our guide to Global Privacy Control.
What Shopify does not control is code that runs outside these systems: scripts pasted into theme.liquid, old tracking snippets left in theme files, and some app embeds. Those follow consent only if they check the API themselves or you block them.
Option 1: Shopify's built-in cookie banner
The built-in banner is free and passes choices to the Customer Privacy API automatically. According to Shopify's help center, you turn it on like this:
- In the Shopify admin, go to Settings → Customer privacy.
- Click Cookie banner.
- Choose where it shows. Newer stores may have automated region settings turned on by default. You can switch to manual settings to pick countries and regions yourself.
- Adjust the text, buttons and appearance, and save.
The built-in banner is a sensible default for many stores. Its limits are usually around design control, the depth of preferences, consent records and multi-site management. It also only governs what the Customer Privacy API governs, so you still need to deal with hardcoded theme scripts, as described below.
Option 2: a consent app from the App Store
Many cookie consent apps integrate with Shopify. A well-built app sets consent through the Customer Privacy API, so Shopify's pixels and checkout follow the visitor's choice. When you compare apps, check:
- that it calls the Customer Privacy API, not just hides a banner,
- whether it can block scripts hardcoded in your theme,
- how it handles regions, Google Consent Mode and Global Privacy Control,
- whether it keeps consent records, and
- what it adds to page weight.
Shopify's help center notes that when you use a third-party banner, its regions need to match the regions configured in your Customer privacy settings.
Option 3: your own banner in theme.liquid
If you run several sites, or already use a consent platform elsewhere, you can add its script to your theme. Shopify supports this through a custom banner setting in Customer privacy.
Step 1: tell Shopify you use a custom banner
In Settings → Customer privacy → Cookie banner, Shopify's help center describes using a third-party banner: remove Shopify's own banner (Remove cookie banner, where available) and set your consent regions (Set custom banner regions), using the same regions as in your banner tool. Shopify's built-in banner then doesn't show, but Shopify still holds back its own cookies and pixels in those regions until your banner records consent.
Step 2: add the banner script
- Go to Online Store → Themes.
- Duplicate your live theme as a backup.
- On the live theme, open the … menu and choose Edit code.
- Open
layout/theme.liquid. - Paste the snippet just after the opening
<head>tag, above other scripts.
<script src="https://cdn.privacyquick.com/v1/privacy.js" data-site-id="pq_xxxxxxxxxx" async></script>
If your theme has other layout files used by some templates, add the snippet there too. You can check with a search across theme files for </head>.
Step 3: pass choices to the Customer Privacy API
Your banner now collects consent, but Shopify doesn't know about it yet. Add a small bridge under the snippet. It listens for PrivacyQuick's pq:consent event, which fires when the visitor makes or changes a choice, and records the matching purposes with Shopify:
<script>
document.addEventListener('pq:consent', function (e) {
var cats = e.detail.categories;
var consent = {
analytics: cats.indexOf('analytics') > -1,
marketing: cats.indexOf('marketing') > -1,
preferences: cats.indexOf('functional') > -1
};
if (!window.Shopify || !window.Shopify.loadFeatures) return;
window.Shopify.loadFeatures(
[{ name: 'consent-tracking-api', version: '0.2' }],
function (error) {
if (error) return;
window.Shopify.customerPrivacy.setTrackingConsent(consent, function () {});
}
);
});
</script>
A few notes on this code:
- The
versionvalue comes from Shopify's current Customer Privacy API documentation. Check the docs if the API is updated. - Shopify asks that consent is recorded only in response to a visitor's action, never automatically. The event above only fires on a choice, which fits that rule.
- Shopify handles
sale_of_dataseparately, through a customer-initiated opt-out. If you show a "Do Not Sell or Share" option to US visitors, you can also passsale_of_data: falsewhen they use it. - To confirm it works, make a choice, then run
Shopify.customerPrivacy.currentVisitorConsent()in the browser console. It returns'yes','no'or an empty string for each purpose.
The PrivacyQuick JavaScript API documents the event and the other methods you can use.
Without this bridge, a third-party banner on Shopify only looks like it works. Shopify's own tracking, and every pixel under Customer events, keeps following Shopify's stored consent, which your banner never updated.
Blocking scripts hardcoded in your theme
Older stores often have tracking code pasted directly into theme.liquid or snippets: a Google Analytics tag, a Meta Pixel, a TikTok Pixel, a heatmap tool. These run regardless of the Customer Privacy API. You have two clean options.
Move them to Customer events
Shopify recommends adding tracking through Settings → Customer events, either with an app pixel or a custom pixel. Pixels there run in a sandbox and receive standard events such as page views, add to cart and checkout completed. Shopify runs them only when the visitor's consent allows it. For custom pixels, you set which permissions the pixel needs in its settings. This is also the only supported way to track checkout events, because theme code doesn't run on checkout.
Or block them with your banner
For scripts that must stay in the theme, change their type so they only run after consent:
<script type="text/plain" data-category="marketing" src="https://example-ads.com/pixel.js" async></script>
The script blocking guide shows complete before-and-after examples. Don't do both for the same tool, or you'll double-count events.
Also check Online Store → Themes → Customize → App embeds. Apps that inject scripts there should follow the Customer Privacy API. If you're not sure an app does, ask its developer.
Google, Meta and other sales channel apps
Shopify's Google & YouTube and Facebook & Instagram sales channel apps install their tracking as app pixels. They follow the consent stored in the Customer Privacy API, so you don't need to block them in the theme. For details of what each sends, read the app's own documentation and our guides to Meta Pixel consent and Google Consent Mode v2.
If you added a Google tag by hand in the theme as well, remove the duplicate.
Testing your Shopify consent setup
- Run a cookie scan of your storefront to see which cookies and third-party hosts appear before any choice.
- Open the store in a private window from a region where you require consent, or use a VPN.
- Before choosing, check the Network tab: no ad or analytics requests should leave the page.
- Click Reject all, then check
currentVisitorConsent()in the console. - Accept all, add a product to the cart and start checkout. Confirm that your pixels now fire.
- Repeat from a region where you don't require opt-in, to check the experience there. Our guide to opt-in vs opt-out consent explains the difference.
On another e-commerce platform? See our guides for Magento and Adobe Commerce, BigCommerce and WooCommerce.
Your store also needs a policy: see privacy policy for a Shopify store.
Next steps
- Pick your route: built-in banner, an app, or an external banner bridged to the Customer Privacy API.
- Move hardcoded tracking to Customer events, or tag it so it waits for consent.
- Match your banner's regions to your Customer privacy settings.
- Update your store's privacy and cookie policies. Our guide to an online store privacy policy covers what to include.
- Re-test after installing any new app.
Frequently asked questions
Does Shopify have a free cookie banner?
Yes. Shopify includes a cookie banner you can turn on under Settings → Customer privacy. It passes visitors' choices to Shopify's Customer Privacy API automatically, though its customization options are more limited than many apps.
Does Shopify's cookie banner block my theme scripts?
Not on its own. Shopify's own cookies, Shopify-managed pixels and apps that use the Customer Privacy API follow the visitor's choice, but scripts you or a developer hardcoded in theme files run unless they check consent or are blocked another way.
Where do I add custom head code in Shopify?
In the theme code editor: Online Store → Themes, open the menu for your theme, choose Edit code, then open layout/theme.liquid and paste the code inside the head element. Duplicate the theme first so you can roll back.
Does the cookie banner appear on Shopify checkout?
Theme code in theme.liquid doesn't run on Shopify's checkout pages, so a script-based banner isn't shown there. Because consent is stored through the Customer Privacy API, Shopify's checkout and the pixels you manage under Customer events can still follow the choice the visitor made on your storefront.
Check your own website in 30 seconds
Our free scanner lists every cookie and tracker your site sets, sorted into categories, before you add a banner.
This guide is general information, not legal advice. Laws and regulator guidance change; check the current rules for your situation or ask a lawyer.