Benson for WooCommerce
Block coupon extensions: hide pop-ups through checkout, limit codes to your allowlist in extension sessions, and see orders from those sessions.
Install in
Benson measures how coupon and cashback browser extensions (Honey, Capital One Shopping, Rakuten and others) affect your store. This plugin connects WooCommerce to your Benson account:
- Adds the Benson script to every page, checkout included. It loads asynchronously, so it never blocks rendering, and it is kept out of cache plugins’ “delay JavaScript” and combine settings so it runs on time. The Benson blocker rules you set up in the dashboard apply on the checkout page too.
- Attributes your orders. When a shopper’s consent allows it, the plugin records the Benson session, the coupon extensions detected in it, the tools Benson loaded in it and any holdout it was part of on the order. Paid orders are then sent to Benson (amounts, codes, the session; never customer details), so your dashboard shows revenue, conversion and discount depth for shoppers with and without an extension. Cancelled and refunded orders are updated, and a daily check catches anything missed.
- Applies your strict code policy on the server. When the Benson script has detected a coupon extension in a shopper’s browser, it stores a signed note in a first-party cookie (
bn_ext), which the plugin also keeps in the shopper’s WooCommerce session. When a coupon is applied in such a session, the plugin asks Benson whether the code is on your extension allowlist. If it isn’t, WooCommerce rejects the coupon with the message you wrote in Benson. Shoppers without an extension are never affected, and coupons you add to an order in wp-admin are never checked. - Applies your partner code locks (beta). When you lock a partner’s code in Benson, the Benson script notes which partner sent the shopper in a first-party cookie (
bn_aff, only with consent). When a locked code is applied, the plugin asks Benson whether it applies in this session: it does for the shoppers that partner sent, and not when another partner sent the session or a coupon extension is active in it. Other coupons are never checked: the plugin reads which codes are locked (as hashes) from your site’s public config, at most every five minutes. - Refuses a code at checkout for the shoppers it isn’t meant for (beta). When you switch “Refuse at checkout” on for a code in Benson, the Benson script notes in a first-party cookie (
bn_src, only with consent) whether the visit came from a coupon site, has a coupon extension running or followed an affiliate link. When that code is applied in such a visit, the plugin asks Benson whether it applies. Other coupons, and visits from none of those, are never checked: the plugin reads which codes are refused (as hashes) from the same public config. - Fails open. If Benson doesn’t answer within one second, or answers with an error, the coupon is judged by WooCommerce alone, as if the plugin weren’t there.
- Syncs your coupon codes (optional, on by default) so they appear in your Benson allowlist: code, discount type and amount, minimum spend, expiry, whether the coupon is restricted to specific customer emails, and whether its value comes off the whole cart (no product, category or brand limits, no sale-item exclusion, item limit or maximum spend). No customer or order data is sent.
- Sends a daily coupon usage summary for your Benson store audit: over the last 30 days of paid orders, the order count, revenue, how many orders used a coupon, and per coupon code the number of orders and the total discount. Only totals are sent.
- Works with the discount widget. On shop, product, cart and checkout pages it gives Benson’s widget your cart (from the WooCommerce Store API) and applies the codes it offers, with WooCommerce validating them as usual. The plugin adds three values to the Store API cart so the widget can say what a whole-cart coupon saves: the cart’s subtotal, whether a figure can be shown, and a one-unit safety margin for stores that show prices with tax. It shows no figure where WooCommerce’s own discount could differ (prices entered without tax but shown with it, or the other way round, a store showing a different number of decimals from its currency, another plugin that changes coupon amounts, or two coupons on the cart).
- Puts your offers where you want them. Add the “Benson offers” block in the block editor (posts, pages and, on block themes, templates such as Single Product), or the
[benson_offers]shortcode anywhere shortcodes work. Benson shows your inline discount widget campaign there. Name one campaign with its ID from Benson ([benson_offers campaign="cmp_…"], or the block’s Campaign ID setting); leave it out for the first inline campaign that matches the page. With nothing to show it takes no space. Both print one empty element and load nothing of their own. - Counts AI crawlers. AI crawlers and fetchers (GPTBot, ClaudeBot, PerplexityBot, ChatGPT-User and others) don’t run JavaScript, so only your server sees them. When one requests a storefront page, the plugin tells Benson which bot (by user agent), the page path and the response status, so your dashboard shows which pages AI reads. It never waits for the answer.
- Follows the WP Consent API. With a consent plugin that supports it, Benson’s cookies and storage follow the shopper’s choice for the “statistics” category, and tools that need “marketing” or “preferences” consent load only when the shopper gave it.
Background jobs run on Action Scheduler (WooCommerce Status Scheduled Actions, group benson). The settings page shows the connection, the last heartbeat, coupon sync and order push, and the last error.
What it can’t do: the extension cookie only exists once the Benson script has seen an extension in that browser, so a code entered before detection (or with cookies disabled or not consented to) is judged by WooCommerce alone. Orders placed without consent arrive unlinked.
External services
This plugin connects the store to Benson (https://trybenson.com), the service it is built for, at the API URL you set (by default https://api.trybenson.com). It sends:
- Connect to Benson. Only when you click “Connect to Benson” on the settings page: your browser goes to
/api/woocommerce/connect/startwith the store’s address, name, currency and time zone, the address of the page to come back to, and a hash of a one-time secret the plugin keeps. Once you connect the store in Benson, your server sends the one-time code Benson returned, with that secret, to/api/woocommerce/connect/exchangeand receives the site key, a policy key, the store’s name in Benson and its dashboard address. - The Benson script and its config. Every storefront page loads
benson.jsfrom the API URL, which then reads your site’s public config from/v1/c/<site key>. The script runs in the shopper’s browser and follows the consent mode you set in Benson. - The connection check. When your keys are saved, once a day, and when you click “Check connection”, the server reads
/v1/c/<site key>and sends your site key to/v1/policy/heartbeat, so Benson can show the plugin is installed. On sites with partner code locks or codes refused at checkout, the server also reads/v1/c/<site key>at most every five minutes when a coupon is applied, for the hashed lists of those codes. - The policy check. When a coupon is applied in a session with a
bn_extnote, the server sends your site key, the note (a session id, extension ids, an expiry and a signature) and the coupon code to/v1/policy/check. When a locked partner code is applied, it also sends the session’s partner frombn_aff(a network and partner id, or-for none), the Benson session id and the extension ids detected in the session. When a code you refuse at checkout is applied in a visit from a coupon site, with a coupon extension or through an affiliate link, it also sends which of those three the visit showed (frombn_src, as the letterss,xanda) and the Benson session id. - Coupon sync (optional). When coupons change and once a day, the server sends your coupon codes and their discount settings to
/api/sites/<site key>/discount-codes/import, authenticated with your policy key. - The usage summary. On activation, when your keys are saved, and once a day, the server sends the 30-day coupon usage summary (totals only) to
/api/sites/<site key>/discount-codes/usage-summary, authenticated with your policy key. - AI crawler hits. When a storefront page is requested by a known AI crawler or fetcher (matched by user agent), the server sends your site key, the bot’s user agent, the page path (no query string), the time and the response status to
/v1/f, without waiting for an answer. Requests from people are never sent. Thebenson_ai_fetch_enabledfilter turns it off. - Orders (optional). When an order is paid, cancelled or refunded, and once a day for recent orders, the server sends the order’s id and number, dates, currency, amounts, coupon codes with their discounts, the Benson session id, detected extension ids, the keys of the tools Benson loaded, the session’s experiment and holdout assignments, the referrer’s host and
utm_sourcefrom WooCommerce’s order attribution (never the referrer URL) and whether it’s a test order to/api/sites/<site key>/orders/import, authenticated with your policy key. No customer details are sent.
Benson’s terms of service: https://trybenson.com/legal/terms
Benson’s privacy policy: https://trybenson.com/legal/privacy
Developer hooks
benson_coupon_denied(action,$code, $result, $tag): a coupon was refused by the policy, just before WooCommerce shows the message.benson_policy_check_result(filter,$result, $code, $tag): Benson’s answer before WooCommerce acts on it.nullmeans Benson didn’t answer (allowed). Returnarray( 'allow' => true )orarray( 'allow' => false, 'message' => '…' ).benson_loader_attributes(filter,$attrs): attributes on thebenson.jstag, e.g.data-consent=>required.trueprints a bare attribute,falseremoves one.benson_coupon_sync_limit(filter,$limit): coupons per sync, newest first (1 to 5,000; default 5,000).benson_order_payload(filter,$payload, $order): the order Benson receives. Returnfalseto skip the order. Only the documented fields are sent.benson_ai_fetch_enabled(filter,$enabled, $ua): whether to report this AI crawler request to Benson (defaulttrue).
Written by Joobi from the project's own listing. See the source page
1.6.0
- Saving figures for coupons: the discount widget can say what a percentage or fixed cart coupon saves on the basket, and lead with the one that saves most. The coupon sync now says whether each coupon comes off the whole cart, and the Store API cart carries the subtotal the widget works it out on. Coupons limited to some products, categories or brands, to full-price items, to a number of items or by a maximum spend get no figure.
- Coupon sync sends amounts in the currency’s minor unit whatever number of decimals the store shows prices with.
- The “Benson offers” block and the
[benson_offers]shortcode put your inline discount widget campaign in a page, a post or a block template. Leave the campaign out to show the first one that matches the page, or copy one campaign’s ID from Benson. - Refuse at checkout (beta): a code you refuse at checkout in Benson is checked on the server too, for visits from a coupon site, with a coupon extension or through an affiliate link. The check sends which of those the visit showed and the session id; other coupons, and visits from none of them, are never checked.
1.5.0
- Connect to Benson: one button on the settings page creates your free Benson account or signs you in, connects the store and brings back its site key and a policy key. No keys to copy. Pasting keys still works.
- The settings page leads with the connection: what’s connected, Open Benson and Visit your store. The keys and switches fold away under “Keys and settings”.
- A notice on the Plugins screen points to Connect to Benson until the store is connected.
1.4.0
- Partner code locks (beta): a code you lock to a partner in Benson is checked on the server too. The check sends the session’s partner, the session id and the detected extension ids; the plugin reads which codes are locked (hashed) from your site’s public config at most every five minutes, and checks no other coupon.
1.3.1
- Orders carry the referrer’s host and
utm_sourcefrom WooCommerce’s own order attribution, so Benson can credit orders that came from AI assistants even when its script didn’t see the visit. The referrer URL is never sent.
1.3.0
- Reports storefront requests from AI crawlers and fetchers (user agent, path, status) to Benson’s crawler report. New
benson_ai_fetch_enabledfilter.
1.2.0
- Records which tools Benson loaded and holdout exposures on orders; WordPress Consent API purposes for tools.
1.1.0
- Order attribution: paid orders, with the Benson session and detected extensions, are sent to Benson (classic and block checkout), updated when cancelled or refunded, and reconciled daily. New “Send orders to Benson” setting.
- The discount widget gets the WooCommerce cart and applies its codes through the Store API.
- Follows the WP Consent API where the Benson consent mode leaves consent to the page.
- Status panel and “Check connection” on the settings page.
- Policy check answers are reused for five minutes; failures for a minute.
- The extension note is kept in the WooCommerce session, so deleting the cookie no longer skips the policy.
- Coupons added to orders in wp-admin are never checked.
- Background jobs run on Action Scheduler.
- benson.js is excluded from JavaScript delay and combine in common cache plugins.
- The usage summary counts every paid status (
wc_get_is_paid_statuses()). - Developer hooks:
benson_coupon_denied,benson_policy_check_result,benson_loader_attributes,benson_coupon_sync_limit,benson_order_payload.
1.0.0
- First release: the Benson script, the server-side code policy check, coupon sync, and the coupon usage summary.
Follow this listing's changes (Atom feed)