GateCheck

How to Add a CAPTCHA to Any Website

A CAPTCHA asks a visitor to complete a challenge when a site needs more confidence that a request comes from a person. It can add friction, so use it for a clear reason and make sure the server checks the answer before accepting the protected action.

Published

Choose the point where a challenge belongs

A CAPTCHA is most useful as one step in a decision, not as a replacement for every other safeguard. You might ask for one before a form submission or after a request has been flagged for extra review. If the site shows a challenge on every page, people who came to read a public page may face unnecessary work.

Plan the complete flow: show the challenge, receive its response token, send that token to a server, and have the server ask the CAPTCHA provider to verify it. Only then should the application continue with the action. A browser can be changed or bypassed, so JavaScript that merely displays a success message is not a server-side verification.

Know the available provider options

Cloudflare Turnstile, Google reCAPTCHA, and hCaptcha are separate services with their own setup, keys, documentation, and verification endpoints. Their products and challenge behavior can change. Compare the current provider documentation, the data each provider says it receives, the site domains allowed for a key, and the integration steps before selecting one.

Google reCAPTCHA has v2 options, including a checkbox, and v3, which returns a score for an action rather than presenting the same checkbox flow. hCaptcha and Turnstile have their own widget and server-verification processes. Avoid assuming that a provider token from one product can be checked by another; use the matching provider API and secret key.

  • Turnstile: Cloudflare CAPTCHA service with its own site and secret keys.
  • reCAPTCHA v2: Google challenge options that can include a checkbox.
  • reCAPTCHA v3: Google score-based response that the application must interpret.
  • hCaptcha: a separate provider with its own widget, keys, and verification flow.

Install the widget and verify its answer

Register the website with the chosen provider and configure the exact hostnames that should use the key. Add the provider widget to the page or form, then submit its response token alongside the form data to your own server. The server should send the token and secret key to the provider verification endpoint, check the response, and reject missing, expired, or invalid results.

Keep the secret key only on the server. Do not put it in HTML, JavaScript bundles, public configuration files, or a URL. Decide what to do if the provider is unavailable: fail closed for an action that must not proceed without verification, or provide a safe retry path. Log the outcome without storing more visitor data than the application needs.

Use GateCheck with a CAPTCHA

GateCheck can ask a visitor to solve a CAPTCHA when its visit rules require one. On GateCheck-hosted challenge pages, the default is GateCheck’s CAPTCHA, which GateCheck runs for you. Site owners can instead choose GateCheck’s browser check, which sends nothing to a third party, or their own keys for Turnstile, reCAPTCHA (v2 or v3) or hCaptcha. The page tells visitors which check it uses.

If you host your own challenge page, use your provider keys and the GateCheck ticket flow described in the docs. The ticket identifies the stopped visit; your page obtains the challenge details, displays the selected provider, and sends the answer for verification. Read the current API instructions carefully, because the exact request fields depend on the provider and whether the challenge is on a GateCheck page or your own page.

  • Create your GateCheck site and choose the CAPTCHA behavior in Block page settings.
  • If using your own keys, add the provider keys and allow the required challenge domains.
  • If hosting your own page, follow the ticket and challenge examples in the [docs](/docs#own-pages).
  • Test passing, failing, expired, and unavailable-provider cases.

Make challenges usable

A challenge should explain why a visitor is seeing it and what to do next. Check that the widget works with keyboard input and assistive technology, that errors are announced clearly, and that a person can retry without losing the form they filled out. A CAPTCHA can still be difficult for some people; provide a support or alternate review path where appropriate.

Do not treat every unusual visitor as an attacker. A visitor using a shared network, an older browser, or a privacy tool can be legitimate. Prefer to challenge only when your risk rules call for it, monitor the decisions, and be ready to adjust the rule if ordinary visitors are being stopped.

Test the whole request, not just the widget

Verify that the server checks the token before it creates an account, accepts a comment, or completes another protected action. Try submitting the form with no token, a deliberately invalid token, and a token that has already been used if the provider supports that test. Confirm each case is rejected and the visitor receives a useful message.

Finally, check your provider’s current privacy and retention documentation and update your own visitor notice if needed. The provider may receive information as part of validating a response. GateCheck’s docs describe the choices available in GateCheck; provider behavior and requirements should be checked with the provider itself.

Related guides