User Tools

Site Tools

Translations of this page:


Documentation index


Google ReCaptcha

It's a great way to skip a regular captcha

Here's how to implement it

1. Open, register and get 2 keys

Recaptcha V3 Site key 	
Recaptcha V3 Secret key

2. Add those codes to Rotation - Settings - Social and switch to “Use Captcha on Comments?” in Rotation - Settings

Recaptcha for comments

Google adds a small JS code and checks if a current surfer is a bot, then it adds the result of the check to appointed field

Here's an example for comments (gallery page)

    <title> <!--GALLERY_SLUG--> with reCAPTCHA</title>
     <script src="<!--TUBE_RECAPTCHA_SITE_KEY-->"></script>

function CheckRecaptcha() {
grecaptcha.ready(function() {
    grecaptcha.execute('<!--TUBE_RECAPTCHA_SITE_KEY-->', {action: 'report_form'}).then(function(token) {
       document.add_comment.recaptcha.value = token;

take a look at those tags <!–TUBE_RECAPTCHA_SITE_KEY–>, this is Recaptcha V3 Site key (ie public key)

comments form

<? if ('<!--ERROR-->' != 'OK') echo "error: <!--ERROR-->"; ?>

<FORM name="add_comment" method="POST">
<input type="hidden" name="action" value="add_comment">
<input type="hidden" name="recaptcha" id="recaptcha" value=""> (google adds the result of the check here)

<label>Name:</label> <input class="s_input" type="text" name='username' id='username' value="<?=$user['username']?>">

 <textarea class="s_text" class="ph2" name='comment' id='comment' rows=5 cols=35 value="Leave Your Comments Here"></textarea>

<input type=button value='Send comment' onClick=CheckRecaptcha()> (note that type=button so we check google status bufore submit )

Recaptcha Anticheat

There's a good way to check traffic with google, ie you'll get what amount of traffic Google mark as bot traffic

At any page (in most cases that would be an index page) you have to add

<script src=""></script>
<script src="<!--TUBE_RECAPTCHA_SITE_KEY-->"></script>

req_flag = false;
recaptcha_code = '';

if ('<!--RECAPTCHA_MAX_RATE-->') {
    if (Math.random() > '<!--RECAPTCHA_MAX_RATE-->') req_flag = true;

grecaptcha.ready(function() {
    grecaptcha.execute('<!--TUBE_RECAPTCHA_SITE_KEY-->', {action: 'index_page'}).then(function(token) {
       recaptcha_code = token;

	$('.gallery_link').each(function() {
		    if (req_flag || recaptcha_code === '') return;
		    req_flag = true;

                'action': 'check_recaptcha',
                'recaptcha_code': recaptcha_code,
	        function (data) {



you have to add “class='gallery_link' ” to each link at that page, here's an example

<thumb num=1-10>
<a class='gallery_link' href='/gallery/<!--GALLERY_SLUG-->/index.html'> <!--GALLERY_ID--> </a> <br>

Of course you can replace gallery_link, the idea is to call Google JS each time a user clicks a link

Then you have to go to Settings - layouts and add a column Google Recaptcha

That's it, in an hour take a look at the column Google Recaptcha in trade screen

PS Note that free amount is 1300 hits \ hour so we dont check each hit, but a part of it (RECAPTCHA_MAX_RATE), but if you are ready to pay Google for more - you can remove RECAPTCHA_MAX_RATE (contact support if you have issues removing this parameter)

google_recaptcha.txt · Last modified: 2023/01/09 04:02 by admin