fbpx

Add 30% to your sales 💰 with upsells!Get App

Get 30% sales increase 💰 with upsells!Get App

How to easily add basic Captcha protection on your Shopify blog

How to easily add basic Captcha protection on your Shopify blog

Last Updated on August 24, 2021 by LAUNCHTIP

Since Shopify allows store owners to run built-in blogs, it’s easier for businesses to interact with their customers. But like any other blog, the Shopify blog is also subjected to the nuisance of spam bots. This where a basic Captcha protection is needed. 

Here’s how you can add basic captcha protection to your Shopify blog. 

How to add Captcha protection

The method requires a bit of coding, but it will keep bots away, so it’s worth a shot. 

  • Go to Themes and then to Template Editor 
  • Select article.liquid
  • Add the following code to the file 
<script type="text/javascript">
     $(document).ready(function() {
   	 var n1 = Math.round(Math.random() * 10 + 1);
     	 var n2 = Math.round(Math.random() * 10 + 1);
   	 $("#question").val(n1 + " + " + n2);
  	 $(".comment-form").submit(function (e) {
          	 if (eval($("#question").val()) != $("#answer").val()) {
                     $("#answer").css('box-shadow', '0px 0px 7px red');
              	 e.preventDefault(); 
          	 } 
     	 });
    });
 </script>

 

  • When you come to the end of the form, add this code before submitting: 
<div>
        <br/>How much is: <input type="text" disabled="disabled" id="question"/>
        <br/>Answer:* <input type="text" id="answer"/>
</div>

 

Finally, save the changes, and the captcha code will be added to your blog. 

Benefits of Captcha protection

Captchas are useful in keeping hackers out of your online services, preventing them from submitting nefarious requests. Additionally, they keep hackers from spamming the news content with links to harmful websites or dodgy comments. 

Captcha also increases the security of online shopping for your customers and builds brand trust. Most importantly, it enhances the integrity of your online polls since the bots can’t send false responses. 

Limitations of the method 

Although this method is a useful way to keep bots away, it assumes the following things: 

  • The spambot is not familiar with the post URL 
  • The spambot fills the data instead of posting to the post URL 
  • JavaScript is being used for spamming
Related Posts
Leave a Reply