WooCommerce cookie banner

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.

Design your banner free

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.

SourceCookies or tagsHow it handles consentWhat to do
WooCommerce cart and sessionwoocommerce_cart_hash and woocommerce_items_in_cart (session), wp_woocommerce_session_ (2 days)Set by WooCommerce to keep the cart and checkout workingLeave 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_ cookiesWooCommerce made it compatible with the WP Consent APILet the free plugin share choices through the WP Consent API — or switch the feature off
Google Analytics for WooCommerceGA4 tags with ecommerce eventsSets consent mode defaults denied for the EEA, has no banner of its own and is integrated with the WP Consent APIWorks with the free plugin's choices; nothing to add
Google for WooCommerceGoogle Ads and Merchant Center tagsRecommends a consent tool with a WordPress plugin that's compatible with the WP Consent APISame: the free plugin passes each choice on
WooCommerce Stripe Gateway_stripe_mid, _stripe_sidStripe lists fraud prevention and detection under its essential cookiesDon't block Stripe's script; list its cookies in your cookie policy and decide their category with your adviser
Meta, Pinterest and TikTok for WooCommerceTheir pixelsTheir WooCommerce docs don't say they wait for consentScan 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.

  1. 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
  2. 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
  3. 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.
  4. 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).
  5. 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.
  6. 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.
  7. 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.

CheckHowPasses when
Banner on the first visitOpen the homepage and a product pageThe banner appears, with Accept and Reject side by side
Order Attribution waitsReject, browse two pages, then look at the site's cookies in the browser's developer toolsNo sbjs_ cookies — and they appear after you accept
Google tags start deniedThe free Consent Mode v2 check, or Google Tag AssistantOne consent default with all four v2 signals denied before any Google tag fires
The cart still works after RejectReject, add a product, open the cart and checkoutThe cart keeps its items; woocommerce_cart_hash and wp_woocommerce_session_ are set
Pixels waitReject, then watch the Network tab on a product page and at checkoutNo Meta, TikTok or Pinterest requests
Visitors can change their mindUse the reopen button or a #cookie-settings linkThe 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 · child theme functions.php
<?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.

Consent Mode v2 with Tag Manager on WooCommerce

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.

html · WPCode → Header, top
<!-- 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 -->

WordPress cookie banner guide

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.

Shopify cookie banner guideMagento 2 cookie consent guide

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.

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

Try it on your own site

Design your banner, preview it live, and paste one line. Free for one domain.