Sitecore is a powerful DXP it is desiged for enterprise-level websites. As Marketers you would need to set up your forms and Sitecore provides a solution out-of-the-box to easily create your own forms by drag and drop your form controls like: Text, Buttons, Inputs and customize submit actions. However, your site is vulnerable to bot attacks and some companies prefer to use Google’s reCaptcha to prevent bot traffict to their websites.
I’ve been working on a Sitecore forms module, which support the ReCaptcha Enterprise version within Sitecore Forms. If you want to contribute in the module development please refer the following Github Repo:
https://github.com/RobertoArmas/Sitecore-Forms-ReCaptcha
Installation
To make it easily to install you need to add a Nuget Package in your Webiste project.
Install-Package SitecoreModules.Foundation.Forms
Configuration
To setup the module it is required to add Google ReCaptcha Keys Refer to this google docs: https://cloud.google.com/recaptcha-enterprise/docs/keys
Once you installed the nuget package. The installation will add a config file:
\Website\App_Config\Include\Foundation\SitecoreModules.Foundation.Forms.ReCaptchaEnterprise.nonprod.config.example
You need to clone it and change it accordingly your environment.
Setting | Value |
---|---|
Foundation.Forms.ReCaptchaEnterprise.Api.Url | https://www.google.com/recaptcha/enterprise.js?render={0} |
Foundation.Forms.ReCaptchaEnterprise.Api.SiteVerify | https://recaptchaenterprise.googleapis.com/v1/projects/[PROJECT-ID]/assessments?key={0} |
Foundation.Forms.ReCaptchaEnterprise.PublicKeyV3 | [Public – V3] |
Foundation.Forms.ReCaptchaEnterprise.PublicKeyV2 | [Public – V2] |
Foundation.Forms.ReCaptchaEnterprise.ApiKey | [Api Key] – This is used for Server Side Validation |
Foundation.Forms.ReCaptchaEnterprise.Score | Default to 0.5. |
Finally, you need to ensure that forms.recaptcha.js
is added on standard values to load the js functionality that is required to work, as the following screenshot.
Usage
This module is easy to use. All you need to do is Drag and Drop the control named: “ReCaptcha Enterprise” which is located under Security section.
Then you can configure the module by click on it, then select the mode, it could be:
- Invisible: Provides a better user experience, reCaptcha v3 is invisible for webiste visitors.
- Checkbox: Use a challenge if Google detects a bot behaviour.
Finally, save your form. I hope you find this modue useful on your projects.
Leave a Reply