Powrót do bloga
Technical

Shopify Cookie Consent: The Complete Guide

GetCookies TeamJanuary 1, 20256 min czytania
ShopifyE-commerceImplementationTutorial

TLDR: Add GDPR-compliant cookie consent to Shopify in 3 minutes. Use the GetCookies script in your theme.liquid file. Includes automatic Google Consent Mode v2, pixel blocking, and checkout integration.

Read full summary Shopify stores need proper cookie consent for EU customers. This guide covers theme.liquid integration, conversion tracking with consent gates, and handling Shopify's hosted checkout. Works with all themes including Dawn and Hydrogen. *Summary by Claude AI*
## The $12,000 Email That Changed Everything Last year, a Shopify merchant selling handmade jewelry received an email from a German law firm. A customer had filed a GDPR complaint—the store's Meta Pixel had been firing before consent. The settlement: €11,000 plus legal fees. "I didn't even know my pixel was loading without permission," she told me. "I just installed the Facebook sales channel and assumed Shopify handled it." Shopify doesn't handle it. You do. ## Why E-commerce Faces Higher GDPR Risk Online stores have a unique compliance challenge: | Activity | Data Collected | Risk Level | |----------|---------------|------------| | Product views | Browsing behavior | Medium | | Add to cart | Purchase intent | High | | Checkout | Personal + payment data | Critical | | Retargeting | Cross-site tracking | Very High | Every step of your funnel involves tracking. Every pixel, every app, every script that touches customer data needs consent. ## The 3-Minute Shopify Integration Here's how to make your Shopify store GDPR-compliant: ### Step 1: Get Your Domain ID 1. Sign up at [getcookies.co](https://getcookies.co) 2. Add your Shopify domain (yourstore.myshopify.com or custom domain) 3. Copy your Domain ID ### Step 2: Add to theme.liquid 1. Go to **Online Store → Themes** 2. Click **Actions → Edit code** 3. Open `theme.liquid` 4. Add before ``: ```liquid ``` 5. Save That's it. Your store now has: - GDPR-compliant cookie banner - Google Consent Mode v2 signals - Automatic script blocking - Third-party pixel consent handling ## Blocking Tracking Pixels Until Consent Your Meta Pixel, TikTok Pixel, and Google Analytics should only load after consent. ### Meta Pixel ```liquid {% comment %} Only loads after marketing consent {% endcomment %} ``` The `type="text/plain"` prevents execution. GetCookies activates it after marketing consent. ### Google Analytics 4 ```liquid ``` ### TikTok Pixel ```liquid ``` ## Conversion Tracking: The Right Way ### Thank You Page Tracking Add to **Settings → Checkout → Order status page additional scripts**: ```liquid {% if first_time_accessed %} {% endif %} ``` ### Dynamic Event Tracking Listen for consent changes in real-time: ```javascript window.addEventListener('getcookies:consent', function(e) { if (e.detail.marketing) { // User just gave marketing consent // Fire any queued events if (typeof fbq !== 'undefined') { fbq('track', 'PageView'); } } }); ``` ## Handling Shopify's Checkout ### Standard Shopify Plans Good news: Shopify checkout is on the same domain (or yourstore.myshopify.com). Consent stored in localStorage carries over automatically. The banner won't re-appear on checkout if consent was already given. ### Shopify Plus With Shopify Plus, you can customize checkout.liquid directly: ```liquid {% comment %} checkout.liquid {% endcomment %} ``` This ensures the banner appears in checkout if the user hasn't consented yet. ## Shopify Customer Events (Web Pixels) Shopify's new Web Pixels system runs in a sandbox. GetCookies works alongside it: ```javascript // In your custom web pixel analytics.subscribe('page_viewed', (event) => { // Check consent before tracking if (window.GetCookies?.hasConsent('marketing')) { // Your tracking code } }); ``` For the standard Shopify pixels (Meta, Google, etc.), configure them to use Google Consent Mode—they'll automatically respect GetCookies signals. ## Shopify Markets: Multi-Region Consent For stores selling to multiple regions: ```liquid {% if request.locale.iso_code == 'DE' or request.locale.iso_code == 'FR' or request.locale.iso_code == 'IT' %} {% comment %} Stricter consent for EU {% endcomment %} {% else %} {% comment %} Standard config for other regions {% endcomment %} {% endif %} ``` Or let GetCookies handle geolocation automatically—it detects user location and applies the right regulations. ## Common Shopify Apps and Consent ### Klaviyo Klaviyo respects Google Consent Mode signals. Once GetCookies sets them, Klaviyo adjusts automatically. ### Omnisend Same deal—checks consent signals before tracking. ### PixelYourSite / Pixelfy Configure these plugins to check consent: ```javascript // Check before firing if (window.GetCookies?.hasConsent('marketing')) { // Fire pixel events } ``` ### ReConvert (Thank You Page) Gate your upsell tracking: ```javascript if (window.GetCookies?.hasConsent('marketing')) { // Track upsell conversions } ``` ## Headless Shopify (Hydrogen) For Hydrogen stores built with React: ```tsx // app/root.tsx import { Script } from '@shopify/hydrogen'; export default function App() { return (
G

GetCookies Team

Autor w GetCookies, specjalizujący się w zgodności z ochroną prywatności, zarządzaniu zgodą i optymalizacji marketingu cyfrowego.

Gotowy, aby uprościć zgodę na pliki cookie?

GetCookies sprawia, że zgodność z RODO, CCPA i globalną ochroną prywatności jest bezwysiłkowa. Zacznij dziś.