Skip to content

Instantly share code, notes, and snippets.

@jack2jm
Created January 24, 2024 09:47
Show Gist options
  • Save jack2jm/eab038306ea22b4b6c27bde2c4369416 to your computer and use it in GitHub Desktop.
Save jack2jm/eab038306ea22b4b6c27bde2c4369416 to your computer and use it in GitHub Desktop.
How to set-up your Google reCAPTCHA account?
Before you can use reCAPTCHA, you need to set-up an account.
Once you have your account, you need to add your website domain and obtain a site key and a secret key.
Step 1. Go to the "Admin" page (click the admin button on the top right of the page).
Step 2. Click on the + (plus) symbol on the top bar to create a new site
Step 3. Add a label, for example, add your domain name.
Step 4. Pick the reCAPTCHA type. Pick 'reCAPTCHA v3'.
Step 5. Enter your website domain name
Step 6. Provide the email address of the website owner(s)
Step 7. Read and agree to the terms of service. Tick the box.
Step 8. Receive alerts to your email if your integration is thought to be wrong or an increase of suspicious traffic is suspected
Once the above is completed and the "Submit" button has been pressed. You can continue to obtain your Site Key and Secret Key.
---------------------------------------------
How to get your Google reCAPTCHA Keys?
**********
In order to integrate and use reCAPTCHA v3 on your website, you need to get your reCAPTCHA Keys (Site Key and Secret Key). Here's how to get your keys.
Step 1. Click on the settings icon on the top bar.
Step 2. Expand the reCAPTCHA keys block. Please take a copy of these keys and save them on your computer for later use.
Site KEy and Seceret Key
---------------------------------------------
1. Add this to head section
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
2. Add html code via multiple ways
******** First way via div *********
<div class="g-recaptcha" data-sitekey="reCAPTCHA_site_key" data-callback='onSubmit' data-action='submit'></div>
// here onSubmit is user defined function
function onSubmit(token) {
document.getElementById("demo-form").submit();
}
********Second way - via button click *********
<script>
function onSubmit(token) {
document.getElementById("demo-form").submit();
}
</script>
<body>
<form id="demo-form" action="?" method="POST">
<button class="g-recaptcha" data-sitekey="your_site_key" data-callback="onSubmit">Submit</button>
<br/>
</form>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment