توضیحات
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. - 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, and whether the coupon is restricted to specific customer emails. 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.
- 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, the server also reads/v1/c/<site key>at most every five minutes when a coupon is applied, for the hashed list of locked 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. - 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).
نصب
- In WordPress, go to Plugins Add New Plugin, search for “Benson for WooCommerce”, then click Install Now and Activate. WooCommerce must be active. (Installing from a zip instead? Upload it under Plugins Add New Plugin Upload Plugin.)
- Go to WooCommerce Benson and click “Connect to Benson”. Create your free Benson account or sign in, then connect the store.
- You come back to the same page, connected: the plugin has its site key and a policy key, and the status panel shows Benson knows the store.
Connect to Benson needs the store and its WordPress admin on one https address, like https://yourstore.com (not in a subdirectory, on another port or on plain http). Otherwise paste your keys.
Prefer to paste keys? On the same page, open “Have your keys? Paste them instead” and paste your site key (starts with pk_live_, under Settings Install in Benson) and a policy key (starts with bpk_, created under Protect Checkout and shown once), then save.
The site key alone adds the Benson script. The policy key is needed for the checkout code policy, coupon sync, order attribution and the usage summary.
The server API URL field is only needed when your server must reach Benson at a different address than browsers do. The BENSON_SERVER_API_URL constant in wp-config.php overrides it.
سوالات متداول
-
Does it slow my store down?
-
No. The Benson script is loaded asynchronously and is about 1 KB before it decides what to load. The server only calls Benson when a coupon is applied in a session where an extension was detected, or when a code you locked to a partner is applied (with a one-second limit, and answers are reused for five minutes); everything else runs in the background.
-
What happens if Benson is down?
-
Coupons work as if the plugin weren’t installed (fail-open), orders are sent later by the daily check, and the storefront is unaffected.
-
Does it send customer data to Benson?
-
No. Orders carry ids, the order number, dates, amounts, coupon codes, the Benson session id, detected extension ids, the keys of the tools Benson loaded and the session’s experiment and holdout assignments. Names, emails, phone numbers and addresses are never sent, and the
benson_order_payloadfilter can’t add them. -
Does it work with the Cart and Checkout blocks?
-
Yes. The code policy, order attribution and the discount widget work with both the classic shortcode checkout and the Cart and Checkout blocks (the Store API). The plugin is compatible with High-Performance Order Storage.
-
Will a coupon I add to an order in wp-admin be refused?
-
No. The policy applies to shoppers’ sessions on the storefront only.
-
My cache plugin delays JavaScript. Do I need to exclude Benson?
-
The plugin excludes
benson.jsand its inline lines automatically in WP Rocket, LiteSpeed Cache, Autoptimize, SiteGround Optimizer, W3 Total Cache and Perfmatters. With another optimiser, excludebenson.jsandbensonWoofrom delaying, deferring and combining. -
How does consent work?
-
Benson follows the consent mode set in Benson (Settings Tracking). Without consent it keeps no visitor id and writes no cookies, so orders aren’t linked to a session. With a consent plugin that supports the WP Consent API, and the Benson mode set to Auto or Manual, the plugin passes the shopper’s “statistics” choice to Benson. In every mode, once the consent plugin is active, it also passes the “marketing” and “preferences” choices, which decide whether tools that need them load.
نقد و بررسیها
نقد و بررسیای برای این افزونه یافت نشد.
توسعه دهندگان و همکاران
“Benson for WooCommerce” نرم افزار متن باز است. افراد زیر در این افزونه مشارکت کردهاند.
مشارکت کنندگانترجمه “Benson for WooCommerce” به زبان شما.
علاقه مند به توسعه هستید؟
کد را مرور کنید، مخزن SVN را بررسی کنید، یا از طریق RSS در گزارش توسعه مشترک شوید.
گزارش تغییرات
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.