Banner cookie per Shopify: guida all'installazione
Due metodi di installazione per Shopify — Theme App Extension per Online Store 2.0 e snippet manuale in theme.liquid. Blocco di script, GCM v2, limitazioni del checkout coperte.
Pubblicato il
Shopify added a native consent layer in late 2023 (the Customer Privacy API), which makes adding a cookie banner easier than it was, but also adds a piece of plumbing that not every CMP plays well with. This guide covers both install methods (Theme App Extension and theme.liquid snippet), the Customer Privacy API integration, the checkout limitations on non-Plus plans, and the recurring gotchas.
The two install methods
Method 1: Theme App Extension. If your store is on Online Store 2.0 (most stores created after 2021), your CMP ships as a Theme App Extension that integrates through the Shopify Theme Editor. Install the app from the Shopify App Store, click Add app, then in the Theme Editor turn on the “Cookie Banner” app block. Configuration lives in the Shopify admin under the CMP's app page.
Method 2: theme.liquid snippet. For older themes, or stores that want manual control, paste a script tag directly into theme.liquid. The script loads on every storefront page and renders the banner.
Theme App Extensions are the cleaner choice in 2026 because Shopify validates them, updates ship automatically, and they don't require you to edit theme code (which gets overwritten on theme updates). The theme.liquid route still makes sense for non-OS2.0 themes or for unusual customisations.
The Shopify Customer Privacy API
Shopify released the Customer Privacy API in October 2023 and has been progressively pushing all consent flows through it. It's a JavaScript API in the storefront that lets your site:
- Check the visitor's current consent state (
window.Shopify.customerPrivacy.currentVisitorConsent()) - Update consent state (
window.Shopify.customerPrivacy.setTrackingConsent()) - Subscribe to consent change events
Under the hood, Shopify uses this to gate their own tracking (Shopify Analytics, Shop Pay, etc.) and to feed consent into Customer Events for downstream apps. If your CMP doesn't integrate with the Customer Privacy API, you end up with two consent states fighting: your banner says one thing, Shopify thinks another.
The right pattern is: your banner UI handles the visible consent interaction, and behind the scenes calls the Customer Privacy API to sync the state into Shopify. ConsentTrustee does this automatically when running on Shopify; if you're building your own banner, you need to wire the API calls yourself.
What the theme.liquid snippet looks like
Add this in theme.liquid, inside <head>, before the closing tag:
<script
src="https://cdn.consenttrustee.com/consenttrustee.js"
data-domain="your-domain-slug"
async
></script>Replace your-domain-slug with the slug from your ConsentTrustee dashboard. Use the slug, not your store's *.myshopify.com address or custom domain: the CMP looks up your configuration by slug.
Checkout: the awkward part
Shopify's standard plan locks down checkout.liquid — you can't edit it. Shopify hosts the checkout flow oncheckout.shopify.com with their own templating. Cookie banners can't be injected there on non-Plus plans.
This causes a specific problem: a visitor lands on your store, accepts marketing cookies, adds something to cart, proceeds to checkout. The checkout page is hosted by Shopify, where your banner doesn't run. Their tracking pixels fire based on what Shopify thinks the consent state is, which is what the Customer Privacy API was told from your store pages. If your CMP correctly synced via the API, this works. If it didn't, the checkout pixels behave incorrectly.
For Shopify Plus customers, you can edit checkout.liquid and inject the banner there too, but Shopify is sunsetting this in favour of Checkout Extensions (which are a different system and limit what you can do).
Bottom line: if you're on Shopify standard plans, ensure your CMP integrates with the Customer Privacy API. If you're on Plus, you have more options but the trajectory is toward the same API-driven model anyway.
Google Consent Mode v2 on Shopify
GCM v2 wiring on Shopify works the same way as elsewhere, with one wrinkle: Shopify Analytics is gated by the Customer Privacy API, not by GCM directly. If you also run GA4 (which most merchants do), you need both:
- Banner triggers your CMP's consent update.
- CMP syncs into Customer Privacy API (handles Shopify Analytics).
- CMP fires
gtag('consent', 'update', ...)(handles GA4 and Google Ads).
For the GCM v2 specifics see Google Consent Mode v2.
Common Shopify gotchas
Custom Pixels. Shopify's Custom Pixel feature (in the admin under Customer Events) lets you add tracking scripts that fire on storefront events. By default, these respect Customer Privacy API consent. Make sure your CMP is wired to the API so Custom Pixels respect what visitors actually chose.
Facebook & Instagram by Meta. The official Meta channel app injects the Meta Pixel server-side as well as client-side. The client-side fires before consent unless you tell it to wait. Shopify added consent integration for this in 2024; ensure it's enabled.
Google & YouTube by Google. Similar situation. The Google channel app needs explicit GCM v2 wiring through the Customer Privacy API. As of 2026 this is wired by default in newer installs, but older stores may need to update the app and toggle the consent integration.
Other third-party apps. The Shopify App Store has thousands of apps that inject scripts. Most don't respect Customer Privacy API yet. You have two options: contact the app developer and ask them to integrate, or wrap their injected scripts manually using the script-blocking pattern. Many CMPs (ours included) include auto-detection rules for common app scripts.
What I'd read next
For the legal foundation, GDPR Cookie Consent if you have EU visitors, CCPA if you have California visitors. For Google Tag Manager (which is a common Shopify pattern), Google Tag Manager + Cookie Consent. And for the broader script-blocking pattern, How to Block Third-Party Scripts.