How to effectively enable and validate Google reCAPTCHA v2?

Hi,

I have enabled recaptcha in the preferences on my client’s store but still we are getting a higher number of spams.So I tried integrating recaptcha v2 (checkbox) in the store using the site key. But how to do the server side validation?

I found this piece of code from google search to prevent submission of the form if captcha is not checked.But after displaying the alert ,the form gets submitted. How to do this ?

Can you please help me with the server side code integration ? Is it possible to do it from the contact page liquid file? I tried to get support from the shopify , they suggested to rely on some 3rd party apps.
Any help that could do will be much appreciated.

Thanks