How to Add a Captcha to a Contact Form: Google reCAPTCHA vs Cloudflare Turnstile for Spam Protection
6 min read
For most contact forms, Cloudflare Turnstile is the better first choice because it blocks spam with less friction, while Google reCAPTCHA still makes sense when a team already uses Google tooling or needs risk scoring. A basic contact form can attract junk within days, especially on WordPress, Shopify, custom PHP, and React sites. Google describes reCAPTCHA as a tool that protects websites from spam and abuse [source: Google].
TLDR: A small service business getting 120 spam messages per week could add Turnstile or reCAPTCHA and cut that noise by 90% or more if the form is also rate limited. For example, a plumber with a public quote form may use Turnstile to stop fake “SEO offer” messages without making real customers click traffic lights. Google reCAPTCHA is stronger for teams that want score based rules, such as blocking any submission under a 0.5 confidence score. Turnstile is usually simpler for privacy focused sites and visitors on mobile.
What a CAPTCHA does on a contact form
A CAPTCHA checks whether a form submission looks human. It does not replace server side validation, email filtering, or bot rate limits. It is one layer. A good setup checks the visitor, validates the fields, blocks repeat abuse, and stores enough logs to see what happened.
The contact form process usually works like this:
- The page loads a small script from Google or Cloudflare.
- The visitor fills in the form.
- The CAPTCHA provider creates a token.
- The form sends that token with the message.
- The server checks the token with the provider.
- The message is accepted, rejected, or flagged for review.
The server check matters most. A CAPTCHA added only in the browser is easy to bypass. Bots can post straight to the form endpoint unless the backend rejects missing or invalid tokens.
Google reCAPTCHA: strengths and annoyances
Google reCAPTCHA comes in several forms. reCAPTCHA v2 is the familiar “I’m not a robot” checkbox or image challenge. reCAPTCHA v3 runs in the background and returns a score, often from 0.0 to 1.0. A higher score suggests a more trusted visitor.
Its biggest strength is maturity. Many plugins support it. Many developers already know it. It also works well when the site owner wants flexible rules. For example, a contact form can accept scores above 0.7, send scores from 0.3 to 0.7 to moderation, and reject anything below 0.3.
Honestly, it feels like image challenges still punish real people at the worst time. A user on a phone may need to tap buses, stairs, or crosswalks before sending a simple message. That extra delay can cost leads, especially on emergency service sites.
Best fit for reCAPTCHA:
- Sites already using Google services.
- Forms that need score based filtering.
- Teams with existing reCAPTCHA plugins.
- High abuse forms that need stricter rules.
Cloudflare Turnstile: strengths and annoyances
Cloudflare Turnstile is a CAPTCHA alternative built to reduce visible puzzles. It can run as a visible widget, a non interactive check, or an invisible style challenge. In many cases, the visitor sees little or nothing.
The main win is user experience. A visitor can fill in a name, email, and message without being dragged into an image quiz. Turnstile is also attractive for teams that care about privacy because it does not depend on Google ad profile signals in the same way.
The catch is compatibility. Google reCAPTCHA is supported almost everywhere. Turnstile support is growing fast, but some older form builders still need a plugin, custom code, or a webhook style workaround. Expect to waste time on small settings if the form tool has not kept up.
Best fit for Turnstile:
- Contact forms where low friction matters.
- Privacy focused websites.
- Mobile heavy traffic.
- Sites already using Cloudflare DNS or security tools.
How to add CAPTCHA to a contact form
The exact steps vary by platform, but the pattern stays the same. A developer or site owner needs a site key, a secret key, a frontend widget, and a backend token check.
Step 1: Choose the provider
Pick Turnstile if the goal is fast setup, fewer user complaints, and less visible friction. Pick reCAPTCHA v3 if the site needs silent scoring. Pick reCAPTCHA v2 only when the site owner accepts checkboxes or image prompts.
Step 2: Create keys
In the provider dashboard, the site owner registers the domain. The provider returns two values:
- Site key: safe to show in the page source.
- Secret key: private and used only on the server.
The secret key should never be placed in JavaScript, a public repository, or a theme file that visitors can download.
Step 3: Add the widget to the form
For Turnstile, the form commonly includes a widget container:
<div class="cf-turnstile" data-sitekey="SITE_KEY"></div>
For reCAPTCHA, the markup depends on v2 or v3. A v2 checkbox might use:
<div class="g-recaptcha" data-sitekey="SITE_KEY"></div>
The related script must also load from the provider. Most form plugins handle this step once the keys are saved.
Step 4: Verify the token on the server
When the visitor submits the form, the provider sends a token with the request. The server must post that token to Google or Cloudflare for checking. If the result is invalid, the form should not send the email.
A strong server side rule checks:
- Whether the token exists.
- Whether the token is valid.
- Whether the hostname matches the real domain.
- Whether the token is fresh.
- For reCAPTCHA v3, whether the score meets the chosen limit.
Step 5: Add basic anti spam rules
CAPTCHA works better with simple guardrails. The form should include a hidden honeypot field, rate limits by IP or session, and email validation. It should also reject messages filled with too many links.
A practical rule might be:
- Reject submissions with more than three links.
- Block repeat posts within 20 seconds.
- Hold risky submissions for review.
- Log failed token checks for 30 days.
Google reCAPTCHA vs Cloudflare Turnstile
| Feature | Google reCAPTCHA | Cloudflare Turnstile |
|---|---|---|
| User friction | Can show checkbox or image tests | Often runs with little visitor action |
| Privacy fit | May concern privacy focused teams | Often preferred for privacy sensitive sites |
| Ease of plugin support | Very broad | Good, but not universal |
| Advanced scoring | Strong with v3 | Focused on managed challenge results |
| Best use | Risk scoring and older integrations | Low friction contact forms |
Common mistakes to avoid
The most common mistake is trusting the frontend widget alone. Bots do not need to use the visible form. They can send requests directly to the endpoint.
Another mistake is setting reCAPTCHA v3 rules too aggressively. A strict score limit can block travelers, VPN users, shared office networks, and privacy browser users. A safer first step is to send low score messages to moderation instead of deleting them.
Sites should also show a clear error message. “CAPTCHA failed” is vague. A better message says, “The spam check expired. Please try sending the form again.” That tells a real visitor what happened.
Which one should a site choose?
For a normal business contact form, Cloudflare Turnstile is usually the cleaner choice. It is quiet, fast, and less annoying for real visitors. For a complex system with layered fraud rules, Google reCAPTCHA v3 may offer better scoring control.
The best result often comes from testing both for two weeks. The site owner can compare spam volume, failed submissions, support complaints, and lead conversion. If Turnstile blocks spam without hurting leads, it should stay. If reCAPTCHA scoring gives clearer control, it may be worth the extra setup.
FAQ
Is Cloudflare Turnstile free?
Yes, Turnstile is free for many common website use cases. Site owners should still check Cloudflare’s current terms before using it on large or unusual projects.
Is Google reCAPTCHA free?
Google reCAPTCHA has free options, with enterprise plans available for larger or more advanced needs. Pricing and limits can change, so teams should review Google’s current plan details.
Does CAPTCHA stop all contact form spam?
No. It reduces bot spam, but it does not stop every bad submission. Manual spam, compromised browsers, and paid human spam can still get through.
Can a site use both reCAPTCHA and Turnstile?
It can, but it usually should not. Two CAPTCHA checks can slow the form and annoy real visitors. One CAPTCHA plus rate limiting is cleaner.
Which is better for WordPress contact forms?
Turnstile is often better for simple lead forms. reCAPTCHA may be better if the plugin already has strong reCAPTCHA support and the owner wants v3 score rules.
Should CAPTCHA be added to newsletter forms too?
Yes, if the newsletter form gets fake signups. A hidden honeypot and rate limit may be enough for low traffic forms, but CAPTCHA helps when abuse grows.