I tried to set up reCAPTCHA, on my page by following the instructions here. I signed up for an API key pair and was issued a public key and a private key. It was not clear, to me, how the private key should be used and I could not find more information about it. It does not appear to be used on the page where reCAPTCHA is called.
I edited my page and put
<script src='https://www.google.com/recaptcha/api.js'></script>
before the closing </head>
tag on my HTML template.
I also put
<div class="g-recaptcha" data-sitekey="my-public-key"></div>
where I want my reCAPTCHA widget to appear.
When I load my page, I get the message
Cannot contact reCAPTCHA. Check your connection and try again.
I also see the reCAPTCHA widget with the text
ERROR for site owner: Invalid site key
I have checked similar questions such as this, where the answer says the key is probably invalid but I have just generated it. I also saw this but I did not disable
Verify the origin of reCAPTCHA solutions
You need to ensure your site is added in the domains section of the google reCAPTCHA page where you generated the API key and save. Then test again. That worked for me.