# reCAPTCHA

Galaxy supports Google reCAPTCHA to help protect the website's forms (to protect the leads sent to the backoffice).&#x20;

Its goal is to distinguish between human and automated robots, to avoid receiving spams

{% embed url="<https://www.google.com/recaptcha/about/>" %}
Discover Google's reCAPTCHA official website
{% endembed %}

### Overview

* in the website configuration, enter the 2 API keys
* in the theme code, include Google's reCAPTCHA library
* when a user submits the form, ask reCAPTCHA library to verify the user. reCAPTCHA will give a **token**
* This token needs to be sent with the lead data, with the key `g-recaptcha-response`
* Galaxy will ask Google if the token is valid
  * If everything is good, the lead is sent to the backoffice :tada:
  * If this token is invalid, Galaxy refuses the lead, and the call will fail

### Backoffice configuration

There are 2 API keys to enter in the backoffice:

<figure><img src="https://3028197268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LYM6a76uZePOTen0dIw-887967055%2Fuploads%2FnrFEWtPdskT0cZYc7Hox%2Frecaptcha-configuration.png?alt=media&#x26;token=87ac1391-6ec0-4b64-be5f-94f5d1ad8972" alt=""><figcaption><p>Website parameters to enter</p></figcaption></figure>

### Implementation in the theme

Please **always refer to the last documentation from reCAPTCHA**, to know how to include the API, how to get the token, etc...

{% embed url="<https://developers.google.com/recaptcha/intro>" %}

#### How to get the reCAPTCHA API Key

In the theme, this syntax will call the reCAPTCHA key from the website parameters:

```
{if=" '{{website.google_recaptcha_site_key}}' "}
    {{website.google_recaptcha_site_key}}
{/if} 
```

#### How to send the token to Galaxy

When sending the lead data, include in the data `g-recaptcha-response`, with the token as the value.

#### Handling errors

In the `data` response, make sure to accept the lead only if `data.success` is true
