Cookie Consent Banner
A GDPR-compliant cookie consent banner with granular control over cookie categories, featuring an elegant mobile-responsive design.
Features
Section titled “Features”- GDPR/CCPA Compliant — Full compliance with privacy regulations
- Granular Controls — Separate toggles for necessary, analytics, and marketing cookies
- 12-Month Persistence — localStorage with automatic expiry
- Analytics Integration — Blocks Google Analytics until consent given
- Luxury Design — Frosted glass, gold accents, smooth animations
- Mobile Responsive — Optimized for all screen sizes
- Keyboard Accessible — WCAG 2.1 compliant with focus states
Cookie Categories
Section titled “Cookie Categories”Necessary Cookies (Always Enabled)
Section titled “Necessary Cookies (Always Enabled)”Session management, shopping cart, authentication, security.
Analytics Cookies (Optional)
Section titled “Analytics Cookies (Optional)”Google Analytics, traffic analysis, performance monitoring.
Marketing Cookies (Optional)
Section titled “Marketing Cookies (Optional)”Advertising pixels, retargeting, conversion tracking.
Step 1: Add to Theme Layout
Section titled “Step 1: Add to Theme Layout”The cookie consent snippet is included in layout/theme.liquid before </body>:
{%- render 'cookie-consent', policy_url: pages.cookie-policy.url, analytics_id: settings.google_analytics_id-%}Step 2: Create Cookie Policy Page (Optional)
Section titled “Step 2: Create Cookie Policy Page (Optional)”- In Shopify Admin, go to Online Store > Pages
- Create a page with handle
cookie-policy - Add your cookie policy content
- The banner automatically links to this page
Customization
Section titled “Customization”Colors
Section titled “Colors”Edit CSS variables:
:root { --cookie-gold: #C9A961; --cookie-navy: #1A2332; --cookie-white: #FFFFFF; --cookie-text: #333333;}Translations
Section titled “Translations”Edit keys in your locale file:
{ "cookie_consent": { "banner": { "title": "Your custom title", "description": "Your custom description" } }}Privacy Settings Page
Section titled “Privacy Settings Page”Add a “Manage Cookie Preferences” button to your privacy policy page:
<button type="button" class="button button--secondary" onclick="window.CookieConsent.openSettings()"> {{ 'cookie_consent.manage_preferences' | t }}</button>Legal Compliance
Section titled “Legal Compliance”GDPR (EU)
Section titled “GDPR (EU)”Explicit consent required, granular controls, opt-in before tracking, easy withdrawal.
CCPA (California)
Section titled “CCPA (California)”Opt-out mechanism, clear disclosure, cookie policy link.
Disclaimer: This implementation provides technical features for compliance. Consult with legal counsel for your specific use case.
Testing
Section titled “Testing”- Open your site in incognito mode
- Verify banner appears after short delay
- Test Accept All, Reject All, and Customize buttons
- Check localStorage:
localStorage.getItem('cookieConsent') - Verify Google Analytics only loads after consent
- Test keyboard navigation and screen reader accessibility
Troubleshooting
Section titled “Troubleshooting”Banner not appearing: Check if consent already exists in localStorage. Clear with window.CookieConsent.revoke().
Analytics not loading: Verify analytics ID, check consent status, ensure analytics toggle is enabled.
Styling issues: Check CSS file is loaded, look for z-index conflicts (banner: 9998, modal: 9999).