How to Setup Magento 2 reCAPTCHA?

We understand that the security of an online store is the utmost priority for store owners. In order to protect the store from bots and prevent fraudulent transactions on the store, CAPTCHA is one of the most basic things to set up on your website.

What is CAPTCHA?

CAPTCHA is a type of challenge-response test used in Google computers to check if the user is a human or a robot. Simply put, it is just a process that computes requires to be done by the user to evaluate, it will assess a human being based on the entered results.

Magento comes with a built-in Google reCAPTCHA extension. In this tutorial, we will help you set up Magento 2 reCAPTCHA on your eCommerce store.

Steps to Set up Google reCAPTCHA in Magento 2

Here are the steps to set up Google reCAPTCHA in Magento 2.

Step 1. Install Magento 2 reCAPTCHA

First of all, launch the SSH terminal, connect to your Magento 2 store and go to its root directory. Now, run the following command:

Google Recaptcha Installation

Once done, you will require to fill in repo credentials, username and password which you can receive from your marketplace account. In case you face an error, ‘proc_open(): fork failed – Cannot allocate memory’, it can be solved by enabling Swap space or by running the following command:

Captcha Composer

Post this, enable the module with the following command:

Enable Captch Module

Now upgrade the setup with following command:

Upgrade Command

At last, clean and flush the cache:

Cache Flush

Step 2. Generate Google reCAPTCHA Keys

Go to Google reCAPTCHA and login into your account.

First of all, enter the label for the keys. I'd choose MageDelight reCAPTCHA. 

  1. MageDelight Recapcha

Now, Choose the type of reCAPTCHA.

Here, two types of reCAPTCHA are available.

  • reCAPTCHA v2 - It validates requests with a score.
  • reCAPTCHA v3 - It validates requests with a challenge.

Recaptcha Types

Once done with this, enter the Magento store domains as well as subdomains where you are planning to add reCAPTCHA:

Add Recaptcha magento 2

 

 

 

Now check the Accept the reCAPTCHA terms of service box and Submit.Magento Captcha

Once done with this, you will be redirected to a new page wherein you will find site key and secret key. Copy that, you 'll need it in the next step.

Google Captcha Registration

Step 3. Configure Magento 2 reCAPTCHA

Go to admin panel of your Magento store, and navigate Store-→Configuration

Magento Configuration

Click on Google reCAPTCHA Security Tab:

ReCaptcha

Now, go the General section and enter the Google reCAPTCHA keys that you copied earlier.

Licence Key Magento

Go to backend section and if you are planning to enable Google reCAPTCHA in admin login, select Yes from Enable drop-down:

Magento Backend

Now, go to Frontend and select Yes from the enable drop down and then set the reCAPTCHA as per your requirements.

Recaptcha Front end

Magento Captcha frontnend

Now, at the end, Save the Config:

And it's done! Your store is now secured with the Google reCAPTCHA. Hope we covered everything and if we missed, make sure to update us by contacting us.