WooCommerce cookie banner for GDPR, set up step by step
Free scan: what loads on your site before consent?
Scan your shop's homepage and a product page: see which cookies and trackers start before anyone clicks. No sign-up.
WooCommerce's settings don't include a cookie banner: its privacy settings cover your privacy policy notices and data retention, not cookie choices. Meanwhile WooCommerce's Order Attribution sets sbjs_ cookies on every visit, and Google's WooCommerce plugins wait for consent through the WP Consent API. This guide sets up a banner that speaks that API — the free PrivacyPill plugin — shows what to do with cart, payment and pixel cookies, and ends with a test you can run on a real order path.
Facts checked · Sources
What sets cookies on a WooCommerce shop — and what to do with each
From each plugin's own documentation. Which cookies you see depends on the features and plugins your shop uses.
| Source | Cookies or tags | How it handles consent | What to do |
|---|---|---|---|
| WooCommerce cart and session | woocommerce_cart_hash and woocommerce_items_in_cart (session), wp_woocommerce_session_ (2 days) | Set by WooCommerce to keep the cart and checkout working | Leave them in Strictly necessary — European regulators' example of an exempt cookie is a shopping cart the visitor asked for |
| WooCommerce Order Attribution (on by default since 8.5) | sbjs_session (30 minutes), sbjs_current, sbjs_first, sbjs_udata and other sbjs_ cookies | WooCommerce made it compatible with the WP Consent API | Let the free plugin share choices through the WP Consent API — or switch the feature off |
| Google Analytics for WooCommerce | GA4 tags with ecommerce events | Sets consent mode defaults denied for the EEA, has no banner of its own and is integrated with the WP Consent API | Works with the free plugin's choices; nothing to add |
| Google for WooCommerce | Google Ads and Merchant Center tags | Recommends a consent tool with a WordPress plugin that's compatible with the WP Consent API | Same: the free plugin passes each choice on |
| WooCommerce Stripe Gateway | _stripe_mid, _stripe_sid | Stripe lists fraud prevention and detection under its essential cookies | Don't block Stripe's script; list its cookies in your cookie policy and decide their category with your adviser |
| Meta, Pinterest and TikTok for WooCommerce | Their pixels | Their WooCommerce docs don't say they wait for consent | Scan after rejecting; if a pixel still loads, hold its script back (see below) |
Checked 16 November 2026 on WooCommerce's, WordPress.org's and Stripe's own pages — see Sources.
Set up a WooCommerce cookie banner with the free plugin (7 steps)
The free PrivacyPill plugin (v1.2.3 · WordPress.org listing pending review) runs entirely on your shop: no account needed and no requests to our servers unless you connect one for a consent log.
- 1Scan your shopRun the free check above on your homepage and a product page. Note every cookie and tracker it finds before consent — sbjs_ cookies included.Free pre-consent scan
- 2Install the free pluginDownload the ZIP from the plugin page, then in WordPress go to Plugins → Add New Plugin → Upload Plugin, choose the file, click Install Now and Activate.Free WordPress plugin: download
- 3Install the WP Consent API pluginPlugins → Add New Plugin → search for WP Consent API → Install Now → Activate. It doesn't show a banner itself; it lets WooCommerce's Order Attribution and Google's WooCommerce plugins read the visitor's choice.
- 4Set up the bannerSettings → Cookie consent: wording, privacy policy link, colours and the categories you use. Keep Google Consent Mode v2 on, and keep Advanced → WP Consent API ticked (it's on by default).
- 5Hold back scripts plugins don't gateScripts you pasted into the theme or a header plugin get type="text/plain" and data-pp-category. Scripts a plugin enqueues can be held back by handle with the PHP function shown below.
- 6Clear caches, keep checkout uncachedPurge your page cache so visitors get the new pages. WooCommerce asks that Cart, Checkout and My Account stay excluded from caching — check that's still the case.
- 7Test a real order pathIn a private window: reject, browse, add to cart and open checkout — no sbjs_ or _ga cookies should appear. Accept, and they do. Then run the free scan and the Consent Mode v2 check again.Consent Mode v2 checker
Test checklist: is your WooCommerce banner working?
Run these logged out, in a private window, on the live shop.
| Check | How | Passes when |
|---|---|---|
| Banner on the first visit | Open the homepage and a product page | The banner appears, with Accept and Reject side by side |
| Order Attribution waits | Reject, browse two pages, then look at the site's cookies in the browser's developer tools | No sbjs_ cookies — and they appear after you accept |
| Google tags start denied | The free Consent Mode v2 check, or Google Tag Assistant | One consent default with all four v2 signals denied before any Google tag fires |
| The cart still works after Reject | Reject, add a product, open the cart and checkout | The cart keeps its items; woocommerce_cart_hash and wp_woocommerce_session_ are set |
| Pixels wait | Reject, then watch the Network tab on a product page and at checkout | No Meta, TikTok or Pinterest requests |
| Visitors can change their mind | Use the reopen button or a #cookie-settings link | The preferences open and the new choice applies |
Order Attribution and the sbjs_ cookies
Order Attribution records where each order came from — the referring site, UTM parameters, device type and the number of pages seen — using last-click attribution. It's been on by default since WooCommerce 8.5 and stores that data as order metadata only when an order is placed. Its cookies are sbjs_session (30 minutes) and session cookies such as sbjs_current, sbjs_first and sbjs_udata, which WooCommerce describes as including information about the visitor's user agent, IP, browser and device type.
WooCommerce says it made Order Attribution compatible with the WP Consent API so consent tools can integrate with it. The free PrivacyPill plugin tells the WP Consent API that your site asks for opt-in consent and shares each choice with it, so the test above shows whether Order Attribution waits on your shop. If you don't use its reports, you can switch it off: WooCommerce → Settings → Advanced → Features → Order Attribution.
Google Analytics for WooCommerce and Google for WooCommerce
WooCommerce's Google Analytics extension has no banner of its own. It sets Consent Mode defaults that deny every signal for the EEA, is integrated with the WP Consent API, and WooCommerce's docs say visitors from the EEA, the UK and Switzerland must grant cookie consent before analytics tracking starts. On a site the WP Consent API reports as opt-in — which the free plugin does — a visitor who hasn't answered the banner is reported to Google as denied for every consent type, the extension's documentation says.
The free plugin also sets Consent Mode v2 defaults, all denied, so the two agree. If you'd rather have one default, the extension's woocommerce_ga_gtag_consent_modes filter changes or removes its own (returning an empty array turns it off).
Google for WooCommerce, for Google Ads, recommends a consent tool with a WordPress plugin that's compatible with the WP Consent API and says your setup must update consent after visitors accept. The free plugin does both.
Holding back pixels from other plugins
The docs for Meta, Pinterest and TikTok's WooCommerce plugins don't say their pixels wait for consent. Run the free scan after rejecting. If a pixel still loads, find its script handle in the page source — WordPress prints enqueued scripts as <script id="handle-js"> — and hold it back with the plugin's PHP function in your child theme or a code-snippets plugin:
<?php
// Scripts a theme or plugin enqueues: block them by handle.
// Scripts that depend on a blocked handle wait too.
add_action( 'wp_enqueue_scripts', function () {
if ( function_exists( 'privacypill_consent_block_script' ) ) {
privacypill_consent_block_script( 'some-tracker', 'marketing' );
}
}, 20 );
// Or with the filter:
add_filter( 'privacypill_consent_blocked_scripts', function ( $handles ) {
$handles['some-tracker'] = 'marketing';
return $handles;
} );Scripts that depend on a blocked handle wait too. Prefer Google Tag Manager? Send the pixels through GTM with consent checks instead — the WooCommerce Consent Mode v2 guide shows that setup with GTM4WP.
Stripe and other payment cookies
WooCommerce's privacy documentation lists _stripe_mid and _stripe_sid for the Stripe gateway, alongside the WooCommerce session cookie. Stripe files fraud prevention and detection under its essential cookies, and encourages loading Stripe.js on every page of the shopping experience, not just checkout, because it helps detect fraud. Don't hold Stripe's script back: payments depend on it. Name these cookies in your cookie policy, and decide their category with your privacy adviser — Stripe itself tells customers to check the merchant's site for how its fraud cookies are used.
WooCommerce also recommends saying in your privacy policy that you share data with payment providers such as Stripe or PayPal.
Prefer the hosted banner?
The hosted PrivacyPill script adds the dashboard, the scanner and a proof-of-consent log you can export. Paste it at the very top of the site-wide header with WPCode (Code Snippets → Header & Footer), above any Tag Manager or gtag.js code — the WordPress guide has the full steps.
One difference: the hosted script doesn't talk to the WP Consent API. Without the plugin, Order Attribution doesn't hear the choice, so switch it off if you use the hosted banner. And don't install the WP Consent API plugin on its own: WordPress.org's description says that when no consent plugin declares the consent type, every category returns true.
<!-- PrivacyPill: keep this first in <head>, before Google Tag Manager or analytics -->
<script>window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments)}gtag('consent','default',{ad_storage:'denied',ad_user_data:'denied',ad_personalization:'denied',analytics_storage:'denied',functionality_storage:'denied',personalization_storage:'denied',security_storage:'granted',wait_for_update:500});</script>
<script src="https://privacy-pill-consent-studio.lovable.app/api/public/v1/pp.js?site=pp_your_site_key"></script>
<!-- Then Google Tag Manager or gtag.js, if you add them here yourself -->Block checkout, caching and the banner
Since WooCommerce 8.3 the Cart, Checkout and Order Confirmation blocks are the default for new shops; shops that updated keep their existing checkout. The banner is part of every front-end page either way, so check it on both the cart and the checkout page in the test above.
WooCommerce asks you to keep Cart, Checkout and My Account out of your page cache. The free plugin marks its scripts so WP Rocket, LiteSpeed Cache, Autoptimize and Cloudflare Rocket Loader leave them alone; if you use the hosted script, exclude it from 'delay JavaScript' features yourself.
Selling on Shopify or Magento as well?
Each shop system needs its own catch handled: on Shopify, Shopify's own pixels and checkout follow the choice only through its Customer Privacy API; on Magento 2.4.7 and later, checkout's Content Security Policy blocks scripts that aren't whitelisted.
Frequently asked questions
Sources
Facts on this page come from these pages, read on . Spotted something out of date? Write to kalmwerk@gmail.com and we'll correct it.
- WooCommerce docs: cookies WooCommerce uses
- WooCommerce docs: Order Attribution Tracking
- WooCommerce developer blog: Order Attribution on by default since 8.5
- WooCommerce docs: Accounts & Privacy settings
- WooCommerce docs: Google Analytics for WooCommerce
- Google Analytics for WooCommerce on GitHub: consent mode defaults
- WooCommerce docs: Google for WooCommerce and consent mode
- WordPress.org: WP Consent API
- WooCommerce docs: payment gateways and privacy (Stripe cookies)
- Stripe: cookies policy
- Stripe docs: advanced fraud detection (Stripe.js on every page)
- WooCommerce developer blog: 8.3 makes block checkout the default
- WooCommerce developer docs: configuring caching plugins
- Article 29 Working Party: Opinion 04/2012 on the cookie consent exemption
Using Google Ads or GA4? Check Consent Mode v2
See whether a consent default runs before your Google tags, what the four v2 signals start as, and how to fix it.
Set up PrivacyPill on other platforms
See all- Shopify cookie bannerTested theme.liquid install, Customer Privacy API, apps compared.
- Magento 2 cookie consentHTML Head install, Cookie Restriction Mode, checkout CSP whitelist.
- Squarespace cookie bannerBuilt-in banner vs real blocking, Code Injection, Consent Mode v2.
- Webflow cookie bannerHead code install, Consent Mode v2, Analyze and Optimize consent.
- Wix cookie bannerWix's own banner vs apps vs custom code, and what each holds back.
- Framer cookie bannerFramer's banner component vs custom code, Consent Mode v2, run once.
- HubSpot cookie bannerHubSpot's banner vs your own, setHubSpotConsent, Consent Mode v2.
- Ghost cookie bannerWhen Ghost needs a banner, Code Injection, embeds and native analytics.
- WordPress cookie bannerWPCode or functions.php, classic and block themes.
- Lovable cookie bannerOne prompt to the Lovable agent, or one tag.
- Bolt cookie bannerOne prompt to the Bolt agent, then publish.
- v0 cookie bannernext/script in the root layout, publish to Vercel.
- Next.js cookie bannernext/script beforeInteractive in the root layout.
Try it on your own site
Design your banner, preview it live, and paste one line. Free for one domain.