FormBackend logo
← Back to FormBackend

Spam

Google ReCAPTCHA

Protect your form against spam and bots with Google reCAPTCHA

Google reCAPTCHA v3 helps filter bot submissions. Create keys in Google’s admin, store the secret in FormBackend, and pass the token with each submission.

Setup overview

  1. Create a reCAPTCHA v3 site key at Google reCAPTCHA admin
  2. Add Google’s script to your page (below) and replace YOUR_SITE_KEY in both places
  3. On the form Settings tab, save the reCAPTCHA secret key and the domain that hosts the form
  4. Add a hidden g-recaptcha-response field to your form

Create a reCAPTCHA site key

Create a new key, enter the domain your site is hosted on, and give the key a descriptive name.

How to register a new site with Google reCAPTCHA

That gives you a site key and a secret key:

Shows Google reCAPTCHA credentials

In FormBackend, open the form Settings tab and enter the secret key and hosted domain.

Frontend integration

Add this script to the page that hosts your form, replacing both YOUR_SITE_KEY placeholders:

<script src="https://www.google.com/recaptcha/api.js?render=YOUR_SITE_KEY"></script>
<script>
  grecaptcha.ready(function() {
    grecaptcha.execute('YOUR_SITE_KEY', {action: 'submit'}).then(function(token) {
      document.getElementById('g-recaptcha-response').value = token;
    });
  });
</script>

Then include the hidden response field:

<form action="https://www.formbackend.com/f/{your-unique-token}" method="POST">
  <label for="name">Name</label>
  <input type="text" id="name" name="name" required>

  <label for="email">Email</label>
  <input type="email" id="email" name="email" required>

  <input type="hidden" id="g-recaptcha-response" name="g-recaptcha-response">

  <button type="submit">Submit</button>
</form>

FormBackend verifies the token with the secret key saved on the form.