Home›Trust & Compliance›Setting up bot protection (reCAPTCHA v2, v3 or Cloudflare Turnstile)

Setting up bot protection (reCAPTCHA v2, v3 or Cloudflare Turnstile)

TitanCart ships with built-in bot protection for the storefront forms bots like to hit: customer login, registration, guest checkout and product reviews. It is part of the core plugin, in TitanCart Lite as well as Pro, with nothing extra to buy. You choose one provider: Google reCAPTCHA v2 (the “I’m not a robot” checkbox), Google reCAPTCHA v3 (invisible; Google scores each submission in the background) or Cloudflare Turnstile (a privacy-friendly widget that usually clears itself without a puzzle). This guide covers getting keys from Google or Cloudflare, switching the extension on, picking the forms to protect, and checking it works.

Note: bot protection only guards the storefront. The WordPress admin login (wp-login.php for you and your staff) is never affected, so you cannot lock yourself out of the dashboard.

1. Pick a provider and get your keys

Every provider gives you a matching pair of keys: a Site key (public, used on the page) and a Secret key (private, used by your server to verify each token). The pairs are not interchangeable: a v2 key does not work as v3, and a Google key does not work with Turnstile.

Google reCAPTCHA (v2 or v3)

  1. Sign in at google.com/recaptcha/admin and register a new site.
  2. Give it a label you will recognise, and choose the type: v2 → “I’m not a robot” Checkbox, or v3.
  3. Under Domains add your storefront domain — and the www form and any staging domain you test on.
  4. Submit. Google shows the Site key and Secret key; keep the tab open.

Cloudflare Turnstile

  1. Sign in to the Cloudflare dashboard and open Turnstile in the left-hand menu. A free Cloudflare account is enough; your store’s domain does not have to use Cloudflare DNS.
  2. Click Add widget, name it, and under Hostnames add your storefront domain (and the www form and any staging domain).
  3. Choose the Widget Mode: Managed (Cloudflare decides whether the visitor sees a quick checkbox; recommended), Non-interactive (a small “verifying” box that never asks for a click) or Invisible (nothing shown at all). This choice lives in Cloudflare, not in TitanCart — change it there any time.
  4. Create the widget. Cloudflare shows the Site Key and Secret Key; keep the tab open.

Tip: TitanCart stores the keys for every provider separately and reads only the one you select, so you can register a site with Google and a widget with Cloudflare and switch between them later without re-pasting anything.

2. Enable the extension

Go to TitanCart → Extensions → Installed Extensions, find Bot Protection (reCAPTCHA / Turnstile), make sure it is enabled, and click the gear icon to open its settings page. Enabling it does nothing on its own: the extension stays dormant until both keys for your chosen provider are filled in, so there is no risk of a broken widget while you set up.

3. Choose the provider and paste the keys

The settings page has five sections: Provider, reCAPTCHA v2 Settings, reCAPTCHA v3 Settings, Cloudflare Turnstile Settings and Protected Forms.

  • Under Provider, set the Provider dropdown to Google reCAPTCHA v2 (checkbox widget), Google reCAPTCHA v3 (invisible, score-based) or Cloudflare Turnstile. reCAPTCHA v2 is the default, so a store upgraded from an earlier version keeps working as before.
  • For v2, paste the Site key and Secret key into the v2 section and optionally choose the widget Theme (Light or Dark) and Size (Normal or Compact).
  • For v3, paste the v3 Site key and v3 Secret key into the v3 section and pick the v3 success score (next step).
  • For Turnstile, paste the Site key and Secret key into the Cloudflare Turnstile section. Theme offers Auto (follows the visitor’s system), Light and Dark; Size offers Normal (300 × 65), Compact (150 × 140) and Flexible (fills the form width). Flexible is the one to pick when the widget looks cramped or over-wide in your theme’s forms.

Save. Only the section matching the selected provider is read; the others can stay blank, and only that provider’s script is loaded on the storefront.

4. Set the v3 success score (reCAPTCHA v3 only)

v3 never challenges the visitor. Google returns a score from 0.0 to 1.0 for each submission — higher means more likely human — and TitanCart rejects the submission when the score is below your threshold. The v3 success score dropdown offers 0.9 (strict), 0.7, 0.5 (recommended), 0.3 and 0.1 (permissive). Start at 0.5; lower it if real customers report being blocked, raise it if spam still gets through. TitanCart also checks that the token was issued for the right form, so a token captured on the login page cannot be replayed on checkout.

Turnstile has no score and no threshold: Cloudflare gives a plain pass or fail, and the dropdown is ignored while Turnstile is the provider. Tune Turnstile from the Cloudflare dashboard instead (the Widget Mode, and Cloudflare’s own analytics for the widget).

5. Choose which forms to protect

Each form under Protected Forms has its own switch, and the switches work the same whichever provider you chose:

  • Login form — on by default. The customer login on the My Account page.
  • Registration form — on by default. New-customer sign-up on the My Account page, the “Save your details for next time” card a guest sees on the order-received page, which creates the account the same way, and (since 0.2.79) the REST API’s own registration endpoint, which refuses a request without a valid token.
  • Checkout (guest) — off by default. Applies to guest orders only; signed-in customers are never challenged. A challenge at checkout costs sales, so turn it on only if bot orders are a real problem.
  • Review form — on by default. The product-review form (see Product reviews).
  • Contact form — on by default, but TitanCart has no built-in contact form. The switch only takes effect on a theme contact form that both prints TitanCart’s bot-protection field and verifies it on submit; a theme that only prints the field is not protected.

The provider’s script is loaded only on pages that actually show a protected form, so the rest of the store does not carry it.

Rate limits, and what is not covered. Registration refuses an e-mail that already has an account with “An account with this email already exists.” A script could use that reply to test addresses one by one; with the Registration form protected it cannot submit at all, and even with the switch off the REST registration endpoint accepts at most five attempts an hour from one network address (since 0.2.79) and answers “Too many requests from your network. Please try again later.” beyond that. Two forms are not bot-checked, whatever Bot Protection is set to: the back-in-stock waitlist form on a product page and the newsletter sign-up box. Since 0.2.79 each accepts ten submissions an hour from one network address, which slows a bot without stopping it. A protected version of those two forms is tracked on TitanCart’s side; in the meantime Email Campaigns’ double opt-in (Pro) keeps junk addresses from ever confirming.

6. Test it

  1. Open the storefront in a private window so you are logged out, and go to the My Account page.
  2. reCAPTCHA v2: the “I’m not a robot” checkbox appears under the login and registration forms. Tick it and submit; the form should go through.
  3. reCAPTCHA v3: nothing visible except Google’s small badge in the page corner. Submit normally; a real submission goes through.
  4. Turnstile: in Managed mode a small Cloudflare box appears under the form and usually ticks itself within a second or two, sometimes after a single click; in Non-interactive mode it shows a brief “verifying” state; in Invisible mode nothing is shown. Submit normally once the box has cleared.

A blocked submission shows “Verification failed. Please try again.” above the form, and the form stays on the page — on the My Account page and on a page of your own that carries the account shortcode alike (before 0.2.80 the shortcode’s login form handed a failed check to the WordPress login screen). On checkout and on the review form, submitting before the v2 checkbox or the Turnstile widget has issued its token shows “Please complete the verification.” instead — wait for the widget and try again.

On those two forms the bot check runs before the rest of the form is looked at, and each v2 or Turnstile token is good for one check. Since 0.2.81 a submission the server refuses for some other reason — a review from a customer who has not bought the product or has already reviewed it, or an address the checkout will not accept — gets a fresh widget on the spot: the checkbox clears, or Turnstile runs again, and the corrected form goes through without a reload. On 0.2.81 that covered orders paid by an offline method or PayPal and orders that cost nothing; when the card was entered on the page itself (Stripe, Authorize.net, Square) or the order was paid with Venmo, the widget was not refreshed and a reload was needed after a refused address or a declined card. Since 0.2.82 every payment method refreshes the widget, a declined card included: fix the field or try another card and place the order again. A store running the TitanCart Marketplace extension’s own checkout page gets the same from Marketplace 0.1.18. Before 0.2.81 every second attempt failed with “Verification failed. Please try again.” until the page was reloaded. reCAPTCHA v3 was never affected; it issues a new token on every submit.

Cloudflare publishes test key pairs that always pass or always fail (see the Turnstile documentation under “Testing”). TitanCart treats them like any other key, so you can paste an always-fail secret, confirm every form is refused with “Verification failed. Please try again.”, then paste your real keys back.

How to verify on the provider’s side

The provider’s console is the source of truth for whether tokens reach it and how your traffic is judged. With Google, open your site in the reCAPTCHA admin console and check the Domains list — a missing live domain is the single most common cause of “it always blocks me”. After some real traffic, the analytics show request volume and, for v3, the score distribution; if most legitimate traffic scores 0.7–0.9, a 0.5 threshold is comfortable. Confirm the key type matches the version selected in TitanCart: Google rejects a v2 key used as v3 and vice versa. With Cloudflare, open the widget under Turnstile and check its Hostnames for the same reason; the widget’s analytics show solves, failures and the share of visitors who were challenged.

Troubleshooting

  • The widget or badge never appears. The selected provider is missing a key. The extension stays dormant until both keys for that provider are filled in.
  • Everyone is blocked, even real people. The storefront domain is not in the Domains list (Google) or Hostnames list (Cloudflare), the wrong key pair is in use for the selected provider, or the v3 score threshold is too high. Check the domain list first.
  • “Verification failed” during a network hiccup. Verification is fail-closed: if TitanCart cannot reach the provider within eight seconds, the submission is rejected rather than waved through. Retrying usually works.
  • “Please complete the verification.” on checkout or a review. The form was submitted before the widget had finished; the v2 checkbox was not ticked, or Turnstile was still running. Wait for it and submit again. A Turnstile widget in Invisible mode can take a moment on a slow connection.
  • The Turnstile box is empty or shows an error code. The hostname is missing from the widget in Cloudflare, or your store sends a Content-Security-Policy that does not allow https://challenges.cloudflare.com as a script and frame source — TitanCart does not add that host for you; see Security headers and a Content-Security-Policy for your store.
  • “Verification failed” on my second try at checkout or on a review, after fixing a field. On 0.2.80 and earlier that is every form (section 6). On 0.2.81 it still happens at checkout when the card is entered on the page (Stripe, Authorize.net, Square) or Venmo is selected. Update to 0.2.82 — and, on a Marketplace store, the Marketplace extension to 0.1.18 — where every payment method refreshes the widget; until then reload the page before submitting again.
  • I enabled the Contact form and nothing shows. There is no built-in contact form; the switch waits for a theme that uses the hook.
  • No challenge on the WordPress admin login. Intended. Only the storefront forms are protected.
  • Forms broke after switching provider. The provider you switched to has no keys yet; each provider reads its own fields.

See also

Previous
GDPR & cookie consent
Next
Security headers and a Content-Security-Policy for your store