Add a reCAPTCHA field

Learn how to add a reCAPTCHA field to your forms.

We’re transitioning to a new UI, and are in the process of updating our Webflow University content.

reCAPTCHA is a free service from Google that can help protect form submissions from spam and abuse. The service aims to ensure that your site’s forms are only submitted by real users. Learn more about using reCAPTCHA in forms.

In this lesson, you’ll learn:

  1. How to add reCAPTCHA to forms
  2. How to enable reCAPTCHA validation for a site
  3. How to customize the reCAPTCHA
Important: reCAPTCHA will not function when you’ve set a custom form action to collect your form submissions.
Important: Webflow forms using reCAPTCHA won’t function on exported sites. If you intend to export your site, you’ll need to integrate reCAPTCHA in your forms following Google's reCAPTCHA guide. Also, check out how to collect form submissions on exported sites.

How to add reCAPTCHA to forms

You can add reCAPTCHA to your forms from the Add panel > Elements tab > Forms section. reCAPTCHA elements must be placed into a form.

Important: reCAPTCHA will not display on your published site until you enable validation in Site settings > Forms tab. Please note that this will enable reCAPTCHA validation across all forms on your site, so be sure to include a reCAPTCHA element on all of your forms.
Good to know: reCAPTCHA auto-detects the site visitor’s language and displays the widget in that language.
The reCAPTCHA icon is highlighted in the Forms section of the Add panel.

How to enable reCAPTCHA validation for a site

You can set up reCAPTCHA on your site through the following steps:

  1. Register your site and generate API keys
  2. Enable reCAPTCHA validation

Register your site and generate API keys

  1. Go to Google’s reCAPTCHA page
  2. Choose the reCAPTCHA type: reCAPTCHA v2
  3. Choose the “I’m not a robot” Checkbox

Then, register all domains associated with your site by entering them under Domains. Once you register, you’ll receive 2 API keys (a Site Key and a Secret Key) in your reCAPTCHA settings. You’ll use these when enabling reCAPTCHA validation in the following step.

Note: Make sure to add any custom domains you’re using (e.g., “example.com”). You can also include “example.webflow.io” (replacing “example” with your subdomain) if you’re using the subdomain for publication, staging, or testing. Subdomains for a custom domain are automatically registered. This means registration for “example.com” also registers “subdomain.example.com.” Learn more about Google reCAPTCHA's domain name validation.
Important: Registering domains may take up to 30 minutes to take effect.

Enable reCAPTCHA validation

Important: Before enabling reCAPTCHA on your site, note that enabling reCAPTCHA will enforce validation for all forms on your site. Any forms that do not have a reCAPTCHA element will fail to submit. This change will go into effect immediately after you click Save (step 4 below), whether you republish your site or not. Make sure to add a reCAPTCHA element to each of your forms before you enable reCAPTCHA.

To enable reCAPTCHA validation on your site:

  1. Go to Site settings > Forms tab > reCAPTCHA validation
  2. Paste the API keys from Google (the reCAPTCHA v2 Site Key and the reCAPTCHA v2 Secret Key) — into the corresponding fields
  3. Enable reCAPTCHA validation
  4. Save your changes
  5. Publish your site
Important: For security and correct functionality, make sure to not paste the Secret Key in the Site Key field.
Note: If you prefer to keep designing, or you’re not ready to enable reCAPTCHA for all forms on your published site, you can come back to Site settings to enable it later.

We recommend you check to make sure the form functions correctly on your published site after adding a reCAPTCHA field.

FAQ and troubleshooting

If reCAPTCHA isn’t functioning correctly, here are some issues, warnings, error messages, and how you can fix them.

I can’t see the reCAPTCHA element on my published site

Make sure you’ve enabled reCAPTCHA validation, added a reCAPTCHA element to a form, and republished your site.

Help! My reCAPTCHA element displays “Error: Invalid site key” or  “ERROR for site owner: Invalid site key”

The “Error: Invalid site key” warning appears when 1 or both API keys are incorrect in your Site settings. To fix the error:

  1. Go to your Google reCAPTCHA settings page
  2. Copy your API keys from reCAPTCHA keys

Then, back in Webflow:

  1. Go to Site settings > Forms tab > reCAPTCHA validation
  2. Paste the API keys (the reCAPTCHA v2 Site Key and the reCAPTCHA v2 Secret Key) in the corresponding fields
  3. Save your changes
  4. Publish your site
  5. Clear your cache and test again

My reCAPTCHA element displays “ERROR for site owner: Invalid domain for site key”

The “ERROR for site owner: Invalid domain for site key” warning indicates that you haven’t registered the correct domain(s) for these reCAPTCHA keys. It also appears when you’ve removed the domain(s) registered for this reCAPTCHA. To fix the error:

  1. Add your domain(s) in your Google reCAPTCHA settings page
  2. Save the settings in your reCAPTCHA settings page
  3. Publish your site
  4. Clear your cache and test again
The "ERROR for site owner: Invalid domain for site key" is visible in the reCAPTCHA element. 
Pro tip: If clearing your cache doesn’t work, test in an incognito window. If the reCAPTCHA appears without an error, this will reset the cache for the reCAPTCHA setting. Now, the reCAPTCHA should function correctly in all browsing windows. If the key still doesn’t work, delete the API keys (the reCAPTCHA v2 Site Key and the reCAPTCHA v2 Secret Key) and generate new ones. Then, replace both keys in your Site settings. Please also note that the Site key and Secret key are case-sensitive.

How to customize the reCAPTCHA

reCAPTCHA has limited styling capabilities, but you can customize with custom attributes. Note that styling applied with custom attributes will only appear on your published site.

How to change the reCAPTCHA’s color theme

By default, the reCAPTCHA element has a light theme with a grey background and black text. You can switch it to a dark theme with a black background and white text. To add a dark theme:

  1. Select the reCAPTCHA element on the canvas
  2. Go to Element settings > Custom attributes
  3. Click the “plus” icon
  4. Type “data-theme” in the Name field
  5. Type “dark” in the Value field
A dark theme reCAPTCHA is highlighted in a form.

How to change the size of the reCAPTCHA

The reCAPTCHA element has a default size. You can make it more compact by adding a custom attribute.

To make the reCAPTCHA more compact:

  1. Select the reCAPTCHA element on the canvas
  2. Go to Element settings > Custom attributes
  3. Click the “plus” icon
  4. Type “data-size” in the Name field
  5. Type “compact” in the Value field
A compact reCAPTCHA element is highlighted in a form.

Table of contents

Continue learning

Hmm…we couldn’t find any results for “search query”. Try a different search term or check out our community forum.

Search the forumReset the filter
Load more

Filter

Reset
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Topics
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Back to top