Platform guides
Cookie consent for WooCommerce stores
WooCommerce's cart and session cookies are needed to run the store, but Order Attribution, analytics plugins and ad pixels generally need consent before they run. The work is in finding every plugin that tracks, holding it back until the visitor agrees, and testing the cart and checkout afterwards.
- Plain English
- Written for website owners
- Free to read
On this page
- The cookies WooCommerce sets on its own
- Order Attribution: the sbjs_ cookies
- Analytics and pixel plugins
- Adding the banner and blocking plugin scripts
- Payment gateways and checkout
- Page caching and performance plugins
- Testing your store's consent setup
- WooCommerce consent checklist
- Frequently asked questions
Cookie consent on a WooCommerce store comes down to three jobs. Leave WooCommerce's cart and session cookies alone, because the store can't work without them. Hold back everything that measures or markets, including WooCommerce's own Order Attribution feature, Google Analytics and ad pixel plugins, until the visitor opts in. Then check that your caching setup and checkout still behave. If you sell to people in the EU, EEA or UK, a banner that appears while the Meta Pixel has already fired doesn't meet the consent rules.
This guide assumes you already know how to put a banner script on a WordPress site. If not, start with how to add a cookie banner to WordPress and come back for the store-specific parts.
The cookies WooCommerce sets on its own
WooCommerce documents the cookies it sets on the storefront. As of late 2026, the list looks like this:
| Cookie | Lifetime | What it does | Usual category |
|---|---|---|---|
woocommerce_cart_hash | Session | Helps WooCommerce notice when the cart changes | Necessary |
woocommerce_items_in_cart | Session | Helps WooCommerce notice when the cart changes | Necessary |
wp_woocommerce_session_ (plus a suffix) | 2 days | A unique code that links the visitor to their cart data in the database | Necessary |
woocommerce_recently_viewed | Session | Powers the Recently Viewed Products widget | Functional, or necessary if you treat the widget as part of the requested service |
store_notice[notice id] | Session | Remembers that the shopper dismissed the store notice | Necessary or functional |
The cart and session cookies fall under the "strictly necessary" exemption in Art. 5(3) of the ePrivacy Directive: the shopper put something in a basket, and the store needs to remember it. Our guide to strictly necessary cookies covers the edge cases. WooCommerce also sets a few cookies in the admin area for logged-in staff, such as one for dismissing Marketplace suggestions and an anonymous ID for usage tracking if you enabled it. Those don't affect shoppers.
Two practical notes. First, WooCommerce's cart scripts may also keep a copy of the mini-cart in the browser's session storage, which serves the same purpose as the cart cookies. Second, logging in to a customer account sets WordPress's normal login cookies, which are necessary for the account feature.
Order Attribution: the sbjs_ cookies
Since WooCommerce 8.5, released in early 2024, stores have a feature called Order Attribution, and it was turned on by default. It records where a buyer came from and saves that with the order, so you can see in the order screen and reports whether a sale started from a search engine, a referral or a campaign link.
To do this it uses the Sourcebuster.js library, which writes cookies with an sbjs_ prefix in the visitor's browser: sbjs_session (30 minutes), sbjs_udata, sbjs_first, sbjs_current, sbjs_first_add, sbjs_current_add and sbjs_migrations. According to WooCommerce's documentation, the data it collects includes the referring URL, UTM source, medium, campaign, content and term, the device type and the number of page views in the session. Nothing is saved to the order database unless an order is placed, but the cookies are written on every visit while the feature is active.
Tracking the marketing source of a sale isn't needed to deliver the products, so storing that information on a visitor's device is hard to fit under the strictly necessary exemption. In practice you have three options:
- Turn it off. Go to WooCommerce → Settings → Advanced → Features and disable Order Attribution. If you already track campaigns in GA4 with consent, you may not miss it.
- Let a consent plugin control it. WooCommerce states that the feature is compatible with the WP Consent API, a WordPress feature plugin that passes consent choices between a consent tool and other plugins. If your consent tool supports that API, it can keep attribution off until the visitor agrees. Check WooCommerce's current documentation for how it maps to the API's categories.
- Block its scripts yourself. If your consent tool doesn't use the WP Consent API, you can mark the attribution scripts as analytics or marketing with the
script_loader_tagfilter shown below. Test checkout afterwards.
Run a cookie scan of your store before and after any change. Order Attribution is the most common reason a store that "only uses WooCommerce" still sets non-essential cookies on the first page view.
Analytics and pixel plugins
Most stores add tracking through plugins rather than pasted code: Google Analytics for WooCommerce, Google's and Meta's official WooCommerce integrations, TikTok and Pinterest plugins, email marketing plugins with on-site tracking, and review or chat widgets. Each one decides on its own whether to wait for consent.
Go through them one at a time and look for three things in the settings or documentation:
- Google Consent Mode support. The Google Analytics for WooCommerce extension, for example, supports Consent Mode, integrates with the WP Consent API, and documents a filter called
woocommerce_ga_gtag_consent_modesfor changing the default consent state it sends for EEA, UK and Swiss visitors. Consent Mode only adjusts how Google tags behave; whether you also block the tags until consent is a separate decision, often called basic versus advanced Consent Mode. - A consent integration. Some plugins read the WP Consent API or a specific consent plugin. Others have no consent awareness at all.
- Server-side events. Pixel plugins often send purchase events from your server too, for example Meta's Conversions API. Blocking the browser pixel doesn't stop those. Our Meta Pixel and GDPR guide explains why server events still need a lawful basis and how to pass consent to them.
A plugin with no consent support leaves you two choices: block its scripts with the filter below, or switch off its tracking and add the tag yourself in a form your consent tool can hold back.
Adding the banner and blocking plugin scripts
Put the consent script in the <head> of every page, ahead of any tracking. With PrivacyQuick, that's one tag, added with a header plugin such as WPCode or a wp_head hook with an early priority:
<script src="https://cdn.privacyquick.com/v1/privacy.js" data-site-id="pq_xxxxxxxxxx" async></script>
For scripts that plugins load through wp_enqueue_script(), change the final tag with WordPress's script_loader_tag filter. Find each script's handle in the page source: WordPress gives the tag an id made of the handle plus -js. Then map handles to categories in your child theme or a small custom plugin:
add_filter( 'script_loader_tag', function ( $tag, $handle ) {
$map = array(
'example-attribution' => 'marketing', // replace with real handles
'example-pixel' => 'marketing',
'example-analytics' => 'analytics',
);
if ( empty( $map[ $handle ] ) ) {
return $tag;
}
$tag = preg_replace( '/(<script\b[^>]*?)\stype=([\'"])[^\'"]*\2/', '$1', $tag );
return str_replace(
'<script',
'<script type="text/plain" data-category="' . esc_attr( $map[ $handle ] ) . '"',
$tag
);
}, 10, 2 );
A script marked type="text/plain" doesn't run. PrivacyQuick swaps in a working copy once the visitor allows that category; the script blocking docs show the attribute format for scripts, iframes and images. For the general techniques, including tag managers, see how to block cookies and scripts until consent.
Two store-specific cautions. Never block scripts that the cart, checkout or payment gateway need, such as WooCommerce's own cart scripts or the gateway's checkout script. And watch the browser console after blocking: a plugin may call a function from the script you held back and throw an error that stops other code on the page.
Payment gateways and checkout
Payment providers load their own scripts on the checkout page, and some set cookies for fraud prevention. Stripe's JavaScript, for instance, sets cookies such as __stripe_mid and __stripe_sid for that purpose. Fraud prevention during a payment the customer started is widely treated as strictly necessary, but describe these cookies in your cookie policy and check the provider's own documentation for what it sets.
Keep marketing tags off the checkout and order-received pages until consent is given, the same as everywhere else. Purchase events are exactly what ad platforms want most, which is why so many plugins fire them there. If a visitor rejected marketing, the purchase pixel shouldn't fire.
WooCommerce also has a settings tab for store privacy under WooCommerce → Settings → Accounts & Privacy. It holds the privacy policy notices shown at registration and checkout, and personal data retention settings for inactive accounts and orders in different statuses. These aren't cookie settings, but they belong in the same review. Our guide to an online store privacy policy lists what to disclose about payments, shipping partners and marketing.
Page caching and performance plugins
WooCommerce stores almost always run a page cache, and most caching plugins already leave the cart, checkout and account pages uncached because their content depends on the shopper's session. A hosted banner that makes its consent decisions in the browser works fine on cached product and category pages: the cached HTML is identical for everyone, and the banner script reads the visitor's choice when the page loads.
Trouble usually comes from JavaScript optimization features:
- Delay JavaScript until interaction can stop the banner from appearing until the visitor scrolls or clicks. Add the banner script to the exclusions.
- Combine or minify JavaScript can merge blocked scripts into one file and break blocking. Exclude the banner script and anything marked
text/plain. - Server-side consent checks don't mix with page caching. If a plugin decides in PHP whether to print a tag based on a consent cookie, the first visitor's choice can end up in the cached page for everyone. Prefer tools that decide in the browser.
After every change, purge the plugin cache, your host's server cache and any CDN cache, then test again.
Testing your store's consent setup
- Open the store in a private window, logged out. Many plugins skip tracking for administrators, which hides problems.
- Before clicking the banner, open DevTools and check the Application tab for cookies and the Network tab for requests to analytics and ad domains. WooCommerce's cart cookies typically appear only once something is in the cart, and you should see no
sbjs_cookies unless you've decided they're allowed. - Click Reject all, add a product to the cart, and go through to checkout. The cart must still work, and no pixel or analytics requests should appear.
- Place a test order using your gateway's test mode, if it has one, and confirm nothing marketing-related fired on the order-received page.
- Change your choice to Accept all and repeat. Tags should now load and purchase events should arrive in your analytics and ad accounts.
A free cookie scan gives you a second view of what loads on public pages, though no crawler can complete a real purchase, so the checkout test stays manual.
WooCommerce consent checklist
- Cart, session and checkout cookies are documented as necessary and left alone.
- Order Attribution is either turned off, controlled through the WP Consent API, or blocked until consent.
- Every analytics, pixel and marketing plugin has been checked for consent support, and those without it are blocked or replaced with tagged code.
- Server-side events, such as conversions APIs, respect the visitor's choice.
- The banner script is excluded from delay and combine features, and caches are purged.
- Your cookie policy lists WooCommerce, payment gateway and plugin cookies, and visitors can reopen their settings at any time.
- You re-check after installing plugins and after major WooCommerce updates. For the rest of your WordPress setup beyond cookies, see WordPress GDPR compliance beyond the cookie banner.
Frequently asked questions
Do WooCommerce cart cookies need consent?
Generally no. Cookies such as woocommerce_cart_hash, woocommerce_items_in_cart and the wp_woocommerce_session_ cookie keep the cart working for a service the shopper asked for, which is what the strictly necessary exemption covers. List them in your cookie policy anyway.
What are the sbjs_ cookies on my WooCommerce store?
They come from WooCommerce's Order Attribution feature, which uses the Sourcebuster.js library to remember where a visitor came from, such as the referrer and UTM parameters, so the source can be saved with an order. You can turn the feature off under WooCommerce → Settings → Advanced → Features.
Does WooCommerce have a built-in cookie banner?
No. WooCommerce and WordPress core don't include a consent banner. You need a consent plugin or a hosted consent platform, and you need to make sure your analytics and marketing plugins wait for its signal.
Can I keep page caching on with a cookie banner?
Usually yes. A banner that makes its consent decisions in the browser works with cached pages. Problems usually come from JavaScript delay, combine and defer features, so exclude the banner script from them and keep cart, checkout and account pages out of the page cache as WooCommerce expects.
Check your own website in 30 seconds
Our free scanner lists every cookie and tracker your site sets, sorted into categories, before you add a banner.
This guide is general information, not legal advice. Laws and regulator guidance change; check the current rules for your situation or ask a lawyer.