← Back to Snippets
Cookie Consent Banner
GDPR-compliant cookie consent banner with accept/decline. Remembers user preference via localStorage. Clean design with customizable positioning and colors.
snippets/plynthr-cookie-consent.liquid
{% comment %}
Plynthr — Cookie Consent Banner
https://plynthr.com/snippets/cookie-consent-banner/
INSTALL:
1. Create snippets/plynthr-cookie-consent.liquid
2. Paste this code
3. Add {%- render 'plynthr-cookie-consent' -%} before </body> in theme.liquid
CUSTOMIZE:
- --pcc-bg for background color
- Edit the text/link below
{% endcomment %}
<style>
:root {
--pcc-bg: #1a1a1a;
--pcc-color: #ffffff;
--pcc-btn-accept-bg: #10b981;
--pcc-btn-accept-color: #fff;
--pcc-btn-decline-bg: transparent;
--pcc-btn-decline-color: #999;
--pcc-link-color: #6366f1;
--pcc-radius: 12px;
--pcc-max-width: 420px;
--pcc-bottom: 20px;
--pcc-left: 20px;
}
.plynthr-cookie-banner {
position: fixed;
bottom: var(--pcc-bottom);
left: var(--pcc-left);
max-width: var(--pcc-max-width);
background: var(--pcc-bg);
color: var(--pcc-color);
padding: 20px 24px;
border-radius: var(--pcc-radius);
box-shadow: 0 10px 40px rgba(0,0,0,0.2);
z-index: 10000;
font-size: 13px;
line-height: 1.6;
opacity: 0;
visibility: hidden;
transform: translateY(20px);
transition: all 0.3s ease;
}
.plynthr-cookie-banner.is-visible {
opacity: 1;
visibility: visible;
transform: translateY(0);
}
.plynthr-cookie-banner p { margin: 0 0 14px; }
.plynthr-cookie-banner a {
color: var(--pcc-link-color);
text-decoration: underline;
text-underline-offset: 2px;
}
.plynthr-cookie-banner__buttons {
display: flex;
gap: 8px;
}
.plynthr-cookie-banner__buttons button {
padding: 8px 18px;
border-radius: 8px;
border: 1px solid rgba(255,255,255,0.1);
font: inherit;
font-size: 13px;
font-weight: 600;
cursor: pointer;
transition: opacity 0.2s;
}
.plynthr-cookie-banner__buttons button:hover { opacity: 0.85; }
.pcc-accept {
background: var(--pcc-btn-accept-bg);
color: var(--pcc-btn-accept-color);
border-color: transparent;
}
.pcc-decline {
background: var(--pcc-btn-decline-bg);
color: var(--pcc-btn-decline-color);
}
@media (max-width: 480px) {
.plynthr-cookie-banner {
left: 10px;
right: 10px;
max-width: none;
bottom: 10px;
}
}
</style>
<div class="plynthr-cookie-banner" id="plynthr-cookie-banner">
<p>We use cookies to improve your experience. By continuing, you agree to our
<a href="/policies/privacy-policy">Privacy Policy</a>.</p>
<div class="plynthr-cookie-banner__buttons">
<button class="pcc-accept" data-cookie-accept>Accept</button>
<button class="pcc-decline" data-cookie-decline>Decline</button>
</div>
</div>
<script>
(() => {
const banner = document.getElementById('plynthr-cookie-banner');
const KEY = 'plynthr_cookie_consent';
if (!banner || localStorage.getItem(KEY)) return;
setTimeout(() => banner.classList.add('is-visible'), 1000);
banner.querySelector('[data-cookie-accept]')?.addEventListener('click', () => {
localStorage.setItem(KEY, 'accepted');
banner.classList.remove('is-visible');
});
banner.querySelector('[data-cookie-decline]')?.addEventListener('click', () => {
localStorage.setItem(KEY, 'declined');
banner.classList.remove('is-visible');
});
})();
</script>
Installation
- In your Shopify admin, go to Online Store → Themes → Edit Code
- Under Snippets, click "Add a new snippet"
- Name it
plynthr-cookie-consent - Paste the code above and save
- Open
layout/theme.liquid - Add
{%- render 'plynthr-cookie-consent' -%}just before the closing</body>tag - Update the privacy policy link to match your store's URL
Customization
--pcc-bg— Banner background (default: #1a1a1a)--pcc-btn-accept-bg— Accept button color (default: green)--pcc-link-color— Privacy link color (default: indigo)--pcc-max-width— Banner max width (default: 420px)--pcc-bottom / --pcc-left— Position (default: 20px from bottom-left)
Want this installed for you?
I'll add this to your Shopify store, test it, and make sure it's working perfectly. Done within 24 hours.
Install for Me — $29
✓ Installed & tested
✓ Within 24 hours
✓ Any OS 2.0 theme
FAQ
Is this fully GDPR compliant?
This provides a consent UI. For full GDPR compliance, you'll also need to conditionally load tracking scripts based on the user's choice. Consult a legal professional for your specific requirements.
Can I show it at the top instead?
Yes. Change
bottom to top in the CSS and adjust the transform direction.How do I reset it for testing?
Open your browser DevTools → Application → Local Storage → delete the
plynthr_cookie_consent key and refresh.