A GDPR cookie banner for Shopify that respects your theme — and your speed score
Shopify stores typically load Google Analytics 4, Google Ads, the Meta Pixel and TikTok Pixel through apps and theme code. PrivacyPill sits at the top of theme.liquid, sets Consent Mode v2 before any of them, and forwards each visitor's choice to Shopify's Customer Privacy API so Shopify's own tracking follows along.
Updated 1 October 2026
Set it up in 5 steps
- 1Scan your storefrontRun the PrivacyPill scanner on your store URL to list every pixel and app tag it loads.
- 2Design your bannerMatch your theme's colours and fonts in the customizer and save it to your store's domain.
- 3Edit theme.liquidOnline Store → Themes → ⋯ → Edit code → layout/theme.liquid. Paste the snippet right after <head>.
- 4Connect the Customer Privacy APIThe included listener calls Shopify.customerPrivacy.setTrackingConsent with analytics, marketing and preferences on every choice.
- 5Test in a private windowYou should see the banner, and Shopify's analytics and pixels should wait until you accept.
{%- comment -%} layout/theme.liquid — first thing inside <head> {%- endcomment -%}
<!-- PrivacyPill: keep this first in <head>, before Google Tag Manager or analytics -->
<script>window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments)}gtag('consent','default',{ad_storage:'denied',ad_user_data:'denied',ad_personalization:'denied',analytics_storage:'denied',functionality_storage:'denied',personalization_storage:'denied',security_storage:'granted',wait_for_update:500});</script>
<script src="https://privacy-pill-consent-studio.lovable.app/api/public/v1/pp.js?site=pp_your_site_key"></script>
<script>
window.addEventListener("privacypill:consent", function (e) {
var c = e.detail.consent;
if (!window.Shopify || !Shopify.loadFeatures) return;
Shopify.loadFeatures([{ name: "consent-tracking-api", version: "0.1" }], function (err) {
if (err) return;
Shopify.customerPrivacy.setTrackingConsent(
{ analytics: c.analytics, marketing: c.marketing, preferences: c.functional, sale_of_data: c.marketing },
function () {}
);
});
});
</script>Replace pp_your_site_key with your site key — you'll get it when you save your banner.
Shopify's own banner vs. PrivacyPill
Shopify offers a basic privacy banner through its Customer Privacy settings. It's a reasonable start, but it doesn't block third-party scripts added to your theme, doesn't offer granular categories in all setups, and doesn't send Google Consent Mode v2 on its own. PrivacyPill fills those gaps while still telling Shopify what the visitor chose.
Pixels and apps
Pixels installed through Shopify's Customer Events (web pixels) respect the Customer Privacy API, so they follow PrivacyPill's choice automatically. Scripts pasted directly into theme files should be wrapped with type="text/plain" and data-pp-category so they wait for consent.
Checkout
Shopify's checkout pages are hosted by Shopify and don't run your theme code. Shopify applies the visitor's Customer Privacy consent there, which is another reason to forward PrivacyPill's choice to the API.
Frequently asked questions
Set up PrivacyPill on other platforms
See all- Webflow cookie bannerPaste one line into Head code and publish.
- WordPress cookie bannerWPCode or functions.php, classic and block themes.
- Wix cookie bannerSettings → Custom Code → Head, all pages.
- Squarespace cookie bannerCode Injection → Header on Core plans and up.
- Framer cookie bannerProject Settings → Custom Code, start of head.
- Lovable cookie bannerOne prompt to the Lovable agent, or one tag.
- Bolt cookie bannerOne prompt to the Bolt agent, then publish.
- v0 cookie bannernext/script in the root layout, publish to Vercel.
- Next.js cookie bannernext/script beforeInteractive in the root layout.
- Ghost cookie bannerSettings → Code Injection → Site header.
- HubSpot cookie bannerSite header HTML + setHubSpotConsent sync.
Try it on your own site
Design your banner, preview it live, and paste one line. Free for one domain.