How to Add a Cookie Banner to Your eCommerce Website

How to Add a Cookie Banner to Your eCommerce Website feature image

READING PROGRESS

An online store sets more cookies than a blog. WooCommerce needs cookies to keep the cart working. Your analytics, ad pixels, and order tracking add more on top.

Some of these need the visitor’s consent before they load. Others don’t, and if you block them, your checkout breaks.

This guide shows which cookies a WooCommerce store sets, which ones need consent, and how to add a cookie banner to your WordPress store, then test it.

A cookie consent banner is a bar or popup that tells visitors which cookies your site uses and asks for their choice.

A working banner also blocks non-essential scripts until the visitor agrees. A banner that shows a message while tracking keeps running doesn’t do that job.

Cookies your WooCommerce store sets

WooCommerce core cookies

WooCommerce sets these cookies on the front end of your store. The details come from the WooCommerce cookies documentation, which says none of them stores personal information.

CookieWhat it doesHow long it lastsNeeds consent in the EU and UK?
woocommerce_cart_hashTracks when the cart changesSessionNo. Strictly necessary for the cart.
woocommerce_items_in_cartTracks when the cart changesSessionNo. Strictly necessary for the cart.
wp_woocommerce_session_Links the visitor to their cart data2 daysNo. Strictly necessary for the cart and checkout.
woocommerce_recently_viewedPowers the “Recently Viewed Products” widgetSessionUsually treated as functional. Check with your reviewer.
store_notice[notice id]Remembers that the visitor closed the store noticeSessionUsually treated as functional. Check with your reviewer.

Strictly necessary vs functional

A strictly necessary cookie is one the store can’t work without, such as the cart. A functional cookie makes the site easier to use, such as a recently viewed list, but the store still works without it.

In the EU, only strictly necessary cookies are clearly exempt from consent. A shopping cart is the standard example. See the EU’s Your Europe guide to online privacy.

The same cookie can fall into either group depending on how your store uses it. Classify each cookie by what it does on your site, not by its name.

Order attribution cookies

WooCommerce’s order attribution feature records which channel, such as an ad, a search, or a newsletter, led to each order. It sets sbjs_* cookies, such as sbjs_session (30 minutes) and sbjs_first (session). One of them, sbjs_udata, stores details about the visitor’s device and browser (the user agent). See WooCommerce’s order attribution documentation.

Your store doesn’t need these cookies to work. Treat them as analytics or marketing cookies. If you don’t use the data, turn the feature off in WooCommerce > Settings > Advanced > Features.

Cookies from other tools

Most stores add these on top of WooCommerce:

SourceExample cookiesNeeds consent in the EU and UK?
Google Analytics_ga, _ga_*Yes. The UK’s analytics exception is narrow, and a standard Google Analytics setup may not meet its conditions (see the UK row below).
Meta Pixel_fbp, _fbcYes
Google Ads_gcl_auYes
Payment gateways (Stripe, PayPal)Set by the providerFraud-prevention cookies set during checkout are often treated as strictly necessary. If the gateway’s script loads on every page, not just checkout, those cookies are harder to justify. Check with your reviewer.

Themes and other plugins often add cookies you don’t know about. Run a cookie scan to see what your store actually sets.

It depends on where your customers are and which scripts you run.

You sell to the EU or UK and use analytics or ad pixels. Yes. Those scripts need consent before they load.

You sell in the US. Several US state laws require covered businesses to let visitors opt out of the sale or sharing of their data, including for targeted ads. In practice, that means 3 things:

  1. A “Do Not Sell or Share My Personal Information” link in your footer or banner.
  2. Treating a Global Privacy Control signal as an opt-out, without the visitor clicking anything.
  3. Stopping ad pixels for visitors who opt out. Opt-out is the US default, so these scripts can run until then.

You only use WooCommerce’s cart and session cookies. You may not need consent for those. You still need to list them in your cookie policy.

If you sell to several regions, a geo-targeted cookie banner shows each visitor the banner that fits their region.

This is a summary, not legal advice.

RegionWhat the law asks for
EU: ePrivacy Directive and GDPRThe ePrivacy Directive requires consent before you store or read non-essential cookies on a visitor’s device. The GDPR sets the standard for that consent: freely given, specific, informed, and clear.
UK: PECR and UK GDPRSimilar to the EU. The Data (Use and Access) Act 2025 added a narrow exception for analytics. It applies only when you collect information to produce aggregate statistics that help you improve your site, give visitors clear information, and give them an easy way to object. It doesn’t cover tracking individual visitors or advertising. See the ICO’s guidance on the exceptions.
California: CCPACovered businesses must let visitors opt out of the “sale” or “sharing” of their personal information, which includes cross-context ad targeting. They must also honor Global Privacy Control signals. The law applies only to businesses that meet its thresholds. See the California Attorney General’s CCPA page.
Brazil: LGPDEach use of personal data needs a legal basis, and consent is one of them. Brazil’s data protection authority (ANPD) recommends turning off consent-based cookies by default and showing a clear “Reject” option.
Canada: PIPEDAYou need meaningful consent. For ad tracking, opt-out consent can be acceptable if you explain it clearly and the data isn’t sensitive. Quebec has stricter rules for profiling.

1. Say what you use and why

Tell visitors in plain words what each type of cookie does. For example: “Analytics: helps us see which products people view.” Say what happens if they accept or reject.

2. Offer choices by category

Let visitors accept or reject each category, such as analytics and marketing, on its own. Strictly necessary cookies, such as the cart, stay on and don’t need a toggle.

3. Make “Reject” as easy as “Accept”

In the EU, withdrawing consent must be as easy as giving it. Regulators have acted against banners that hide “Reject” in a second layer or use pre-ticked boxes. Don’t lock the whole store until the visitor chooses.

The banner is a short notice. Your cookie policy gives the detail: each cookie, its purpose, how long it lasts, and who sets it. Link it from the banner.

Your privacy policy covers the rest of the personal data your store collects, such as names and delivery addresses.

5. Design for phones

Many shoppers browse on their phones. Keep the text short, make the buttons big enough to tap, and don’t cover the “Add to cart” button.

Ask returning visitors again after a set period, and whenever you add a new type of tracking. Scan your store again after you install a new plugin or marketing tool.

Under the GDPR, you must be able to show that a visitor consented (GDPR Article 7(1)). Keep a record of each choice and when it was made. See consent logging best practices.

This guide uses WPLP Cookie Consent, a free WordPress plugin. On the free plan, it blocks scripts until the visitor consents, logs each choice in your WordPress database, and supports Google Consent Mode v2 for Google Analytics and Google Ads.

Paid plans add geo-targeting, auto-detect law, IAB TCF, and more scans. See pricing.

Step 1: Install the plugin

  1. Search for WPLP Cookie Consent and click Install Now, then Activate.
  1. Go to WP Cookie Consent > Create Cookie Banner.
  2. Select your applicable privacy law and complete the setup.
Cookie Banner Preview

Step 3: Test your store

  1. Run a cookie scan and verify that cookies are correctly categorized. Cart and session cookies should be marked Necessary.
  2. Reject cookies and test the cart and checkout process.
  3. Check the Network tab in your browser’s developer tools to ensure tracking pixels don’t load before consent.
  4. Accept all cookies and verify that analytics and tracking pixels load correctly.

Troubleshooting

ProblemLikely causeFix
The cart empties after a visitor rejects cookiesCart or session cookies are in a blocked categoryMove them to “Necessary” and scan again
A pixel still fires before consentThe script is hard-coded in your theme or added by another plugin, so the banner doesn’t control itFind it in the scan results and give it a category, or add it through the plugin instead
The banner doesn’t show, or shows again after a choiceA caching plugin is serving an old version of the pageClear the cache, and exclude the consent cookie from caching
Analytics numbers drop after launchVisitors who reject aren’t countedThis is expected. Google Consent Mode v2 can model some of the missing data in Google tools

A cookie banner is one part of store privacy. For the rest, see privacy compliance for WooCommerce stores.

FAQ

If you sell to the EU or UK and run analytics or ad pixels, yes. If you’re a covered business under a US state law, you need a way for visitors to opt out of data sales and targeted ads, and a banner is a common way to offer it.

Not in the EU and UK. Cookies that keep the cart and checkout working are strictly necessary, so they don’t need consent. List them in your cookie policy.

Not if your cart and session cookies are set as “Necessary”. Checkout breaks when those cookies get blocked along with marketing cookies. Test a checkout with all cookies rejected before you go live.

Install a free plugin such as WPLP Cookie Consent, create a banner, and set your cookie categories. The free plan covers one site, with script blocking, consent logs, and Google Consent Mode v2.

Do I need to block the Meta Pixel and Google Ads tags?

For EU and UK visitors, yes, until they consent to marketing cookies. For Google tags, Google Consent Mode v2 tells Google whether the visitor agreed.

Conclusion

A WooCommerce store needs its cart cookies to work and its marketing scripts to wait. A good cookie banner does both.

Check which cookies your store sets, put each one in the right category, and test a checkout with every cookie rejected. Then link your cookie policy and keep your consent records.

Ready to Make Your WordPress Site GDPR Compliant?

Join 30,000+ WordPress sites that trust WPLP Compliance Platform for privacy policies, cookie consent, and compliance documentation.

Get Compliant Today

Generate privacy policies, cookie banners, and compliance documents in minutes.

TABLE OF CONTENTS

Website Compliance

Master Checklist

Stay Compliant! Build Trust!

WRITTEN BY

Picture of Editorial Team

Editorial Team

The WPLP Editorial Team is a group of experienced WordPress professionals, legal compliance experts, and content strategists dedicated to helping website owners navigate the complex world of online legal requirements. With years of hands-on experience in website compliance, privacy laws, and WordPress development, our team ensures that every piece of content is accurate, practical, and easy to implement.

Get compliance updates in your inbox

Weekly privacy law summaries. No spam, ever.

Thanks for signing up for the newsletter!

Related Articles

Get Your Free Website Compliance

Master Checklist

Enter your email below and we’ll send the list straight to your inbox.