Migrate from Google reCAPTCHA
The following tutorial will guide you on how to migrate from Google reCAPTCHA to TrustCaptcha on your website.
Preparation
Section titled “Preparation”You should have already completed the following steps before you start to integrate TrustCaptcha into your website.
Read Get-Started: Get a quick overview of the concepts behind TrustCaptcha and the integration process in get started.
Existing CAPTCHA: If you don’t have a CAPTCHA yet, sign in or create a new user account. Then create a new CAPTCHA.
What changes when you move to TrustCaptcha
Section titled “What changes when you move to TrustCaptcha”Google reCAPTCHA and TrustCaptcha both rely on the same principle: your frontend creates a token and your backend verifies it. The main difference is how the widget looks and how the server-side verification works.
In practice, you will:
- Remove the reCAPTCHA scripts and the
g-recaptchawidget (or yourgrecaptcha.execute()calls). - Add the TrustCaptcha widget and your TrustCaptcha
sitekey. - Replace the token name you send to your backend (
g-recaptcha-response) withtc-verification-token. - Replace your server-side verification call to Google with TrustCaptcha result validation.
Migrate to TrustCaptcha
Section titled “Migrate to TrustCaptcha”Follow these steps to migrate from Google reCaptcha to TrustCaptcha.
1. Remove reCAPTCHA from your frontend
Section titled “1. Remove reCAPTCHA from your frontend”Most reCAPTCHA integrations include a script tag and either a widget element or JavaScript execution code.
Typical examples you may remove:
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<div class="g-recaptcha" data-sitekey="<your_recaptcha_site_key>"></div>Depending on the version, you might also have:
- a different script (for example
.../recaptcha/enterprise.js) - JavaScript like
grecaptcha.execute() - callbacks like
onSubmit(token)ordata-callback="..."
Remove these pieces from your page and from your frontend logic. We will replace them with the TrustCaptcha widget and TrustCaptcha events.
2. Add TrustCaptcha to your frontend
Section titled “2. Add TrustCaptcha to your frontend”TrustCaptcha provides a web component called trustcaptcha-component. It must be placed inside a <form> element and needs a TrustCaptcha sitekey.
<script src="https://cdn.trustcomponent.com/trustcaptcha/3.0.x/trustcaptcha.umd.min.js"></script>
<form> <!-- your input fields -->
<trustcaptcha-component sitekey="<your_trustcaptcha_site_key>" ></trustcaptcha-component>
<!-- further input fields / submit button --></form>When TrustCaptcha completes, it automatically writes a hidden form field named tc-verification-token. You can also listen to the captchaSolved event if you submit the form by JavaScript.
For detailed frontend integrations, use the guides below.
3. Replace the token you send to your backend
Section titled “3. Replace the token you send to your backend”With reCAPTCHA, the token is typically available as g-recaptcha-response. With TrustCaptcha, it is tc-verification-token.
If you submit your form normally, you usually only need to read a different field name on the server.
If you submit via JavaScript, you can read the token from the event:
<script> const trustcaptchaComponent = document.getElementsByTagName('trustcaptcha-component')[0];
trustcaptchaComponent.addEventListener('captchaSolved', (event) => { const verificationToken = event.detail; // Send verificationToken to your backend (e.g., JSON body). });</script>4. Validate the result on your server
Section titled “4. Validate the result on your server”With reCAPTCHA, you usually call Google’s siteverify endpoint (or, for Enterprise, a Google Cloud API) and then interpret fields like success and score.
With TrustCaptcha, your server exchanges the verification token from the form field tc-verification-token for the verification result, using the TrustComponent SDK and an API key of your project (created in the dashboard under API / Integration). Install the SDK as shown in the result validation overview, then fetch the result and decide based on isVerificationPassed and score (0 = probably human, 1 = probably automated):
# The verification id is inside the token (see the result validation overview).curl "https://api.trustcomponent.com/captcha/v3/verifications/{verificationId}/results" \ -H "Authorization: Bearer <your_api_key>"import { TrustComponent } from '@trustcomponent/sdk';
const tc = new TrustComponent('<your_api_key>');
const result = await tc.captcha.getVerificationResult(request.body['tc-verification-token']);if (!result.isVerificationPassed || result.score > 0.5) { // failed or likely automated: reject}use TrustComponent\TrustComponent;
$tc = new TrustComponent('<your_api_key>');
$result = $tc->captcha()->getVerificationResult($_POST['tc-verification-token']);if (!$result->isVerificationPassed() || $result->getScore() > 0.5) { // failed or likely automated: reject}from trustcomponent import TrustComponent
tc = TrustComponent("<your_api_key>")
result = tc.captcha.get_verification_result(request.form["tc-verification-token"])if not result.is_verification_passed or result.score > 0.5: ... # failed or likely automated: rejectimport com.trustcomponent.sdk.TrustComponent;import com.trustcomponent.sdk.model.CaptchaVerificationResult;
TrustComponent tc = new TrustComponent("<your_api_key>");
CaptchaVerificationResult result = tc.captcha().getVerificationResult(request.getParameter("tc-verification-token"));if (!result.isVerificationPassed() || result.getScore() > 0.5) { // failed or likely automated: reject}using TrustComponent;
using var tc = new TrustComponentClient("<your_api_key>");
var result = await tc.Captcha.GetVerificationResultAsync(Request.Form["tc-verification-token"]);if (!result.IsVerificationPassed || result.Score > 0.5){ // failed or likely automated: reject}import trustcomponent "github.com/trustcomponent/trustcomponent-go"
tc := trustcomponent.New("<your_api_key>")
result, err := tc.Captcha.GetVerificationResult(ctx, r.FormValue("tc-verification-token"))if err != nil || !result.IsVerificationPassed || result.Score > 0.5 { // failed or likely automated: reject}require 'trustcomponent'
tc = TrustComponent::Client.new('<your_api_key>')
result = tc.captcha.get_verification_result(params['tc-verification-token'])if !result.is_verification_passed || result.score > 0.5 # failed or likely automated: rejectendlet tc = trustcomponent::TrustComponent::new("<your_api_key>");
let result = tc.captcha.get_verification_result(&form.verification_token).await?;if !result.is_verification_passed || result.score > 0.5 { // failed or likely automated: reject}That is the whole integration. The rest of this page explains the token, the result, how to judge it, the errors and the options.
The result validation overview explains the result, the errors and how to adapt the threshold, in every language of the SDK.
Notes for different reCAPTCHA versions
Section titled “Notes for different reCAPTCHA versions”You do not need four completely different migrations. The general flow is always the same (remove reCAPTCHA → add TrustCaptcha → validate on the server). The only differences are usually how you “trigger” verification and what your UI looked like.
reCAPTCHA v2 Checkbox
Section titled “reCAPTCHA v2 Checkbox”If you used the checkbox version, you likely had a visible widget (<div class="g-recaptcha">...). TrustCaptcha also renders a small box, but it runs automatically and does not ask users to solve puzzles.
If your form previously relied on a “callback” after the checkbox, switch to:
- reading
tc-verification-tokenon form submit, or - listening to
captchaSolved/captchaFailed.
reCAPTCHA v2 Invisible
Section titled “reCAPTCHA v2 Invisible”If you used invisible reCAPTCHA, you often triggered it manually on submit (grecaptcha.execute()).
With TrustCaptcha you can do something similar:
- You can disable autostart (
autostart-disabled="true") and trigger verification manually usingstartVerification(). - If you truly want no visible widget, TrustCaptcha also supports
invisible="true", but it requires a license key. See the widget overview for details.
reCAPTCHA v3
Section titled “reCAPTCHA v3”reCAPTCHA v3 is score-based and usually runs without a visible widget. TrustCaptcha also provides a risk score (score) and a clear decision (isVerificationPassed).
A simple migration approach is:
- Use the TrustCaptcha score the same way you used the reCAPTCHA v3 score.
- Start with a safe threshold (for example 0.5) and adjust it based on your environment and your spam/bot pressure.
reCAPTCHA Enterprise
Section titled “reCAPTCHA Enterprise”Enterprise setups often add product-specific fields and a different server-side API. With TrustCaptcha, the flow stays the same as for all other TrustCaptcha integrations: widget → token → server-side result validation.
If your enterprise logic used actions, risk levels, or multiple thresholds, you can implement the same decision steps using isVerificationPassed, score, and your own multi-step rules.
Next steps
Section titled “Next steps”Once you have successfully installed and configured TrustCaptcha on your website, you can use TrustCaptcha to its full extent. However, we still recommend the following additional technical and organizational measures:
Security rules: You can find many security settings for your CAPTCHA in the CAPTCHA settings. These include, for example, authorized websites, CAPTCHA bypass for specific IP addresses, bypass keys, IP based blocking, geoblocking, individual difficulty and duration of the CAPTCHA, and much more. Learn more about the security rules.
Privacy & GDPR compliance: Include a passage in your privacy policy that refers to the use of TrustCaptcha. We also recommend that you enter into a data processing agreement with us to stay GDPR-compliant. Learn more about data protection.
Accessibility & UX: Customize TrustCaptcha to your website so that your website is as accessible as possible and offers the best possible user experience. More about accessibility.
Testing: If you use automated testing, make sure that the CAPTCHA does not block it. Learn more about testing.