How to add cookie consent to Shopify
You do not need a monthly consent app to put a GDPR cookie banner on your Shopify store. Here is the whole setup: where to host the file, where to paste the code, and how to keep your pixels honest.
Step 1: upload the script to Files
In Shopify admin, go to Content → Files and upload
the-cookie-shooter.js. Shopify hosts it on its CDN. Copy the file
URL, it looks like https://cdn.shopify.com/s/files/.../the-cookie-shooter.js.
Step 2: add it to theme.liquid
Go to Online Store → Themes → Edit code and open
layout/theme.liquid. Paste this right before the closing
</body> tag:
<script>
window.TheCookieShooterConfig = {
siteName: "My Store",
cookiePolicyUrl: "/policies/privacy-policy",
lang: "auto"
};
</script>
<script src="https://cdn.shopify.com/s/files/.../the-cookie-shooter.js" defer></script>
Save, and the banner is live on every page of the storefront. Because
theme.liquid wraps the whole theme, you only add it once.
Step 3: gate your pixels
For consent to mean anything, marketing pixels must not fire before the visitor accepts. On Shopify, trackers usually come from three places:
- Tags you pasted yourself (in theme.liquid or snippets): tag them so they wait for consent:
<script type="text/plain" data-consent="marketing" src="https://connect.facebook.net/en_US/fbevents.js"></script> - Google tags: add Consent Mode v2 defaults in the
<head>of theme.liquid so signals start denied, then the widget flips them to granted on accept. - Sales channel and app pixels (Facebook channel, Google channel, TikTok app): these inject themselves and ignore your banner. Use each app's own consent or region settings, or remove the app and add the tag manually, gated as above.
Test it
Open the store in a private window. The banner should appear, and before you accept, no marketing pixels should fire (check the Network tab). Accept, reload, and confirm your pixels now load and the banner stays away.
Common mistakes on Shopify
- Leaving channel apps to fire pixels regardless of the banner.
- Pasting the script only on the homepage template instead of theme.liquid.
- Forgetting checkout: Shopify locks down checkout pages, so keep tracking there to what Shopify's own consent settings allow.
- Testing while logged in to admin with preview bars that alter behavior, use a private window instead.
A Shopify-friendly banner
One file on your CDN, one tag in theme.liquid, no app subscription. The Cookie Shooter blocks pixels until consent and adds none of its own.
Get The Cookie Shooter See the live demoFrequently asked questions
Do I need an app for cookie consent on Shopify?
No. A lightweight script in theme.liquid works without any app. Consent apps exist, but most add monthly fees and weight.
Does it work with Shopify's own privacy settings?
Yes. The banner is the visible consent step. If you use Shopify's Customer Privacy region rules too, keep them consistent so visitors are not asked twice.
Will it slow down my store?
No. It is a single dependency-free file, and pixels held until consent can make the first load faster.