Skip to main content

Reduce Comment Spam on Blogger with a Simple Javascript Trick

Dealing with comment spam is probably the biggest headache for most bloggers - the comment will have a word like "Cool" or "Interesting" and then a URL pointing to some online pharmacy story selling prescription drugs.

While WordPress has the excellent Akismet anti-spam filter that catches majority of comment spam, Google provides simple word CAPTCHAs and email based comment moderation for Blogger blogs. They also add a rel=nofollow for all links left in the visitor comments section and therefore deny any Google Juice to the linked website.

blog comment spam statistics

Even with these spam prevention measures in place, the problem is far from over. So how do you reduce the menace ? Just turn off comments, not for the entire blog but just for old blog posts.

Why ? Well, if you look at pending comments in your moderation queue that require approval, you'll see a pattern - the blog posts that are more popular in search engines are the biggest target of comment spam.

Blog comment spammers rarely target fresh posts that you have recently published because spammers discover their targets (your blog posts) via search engines and fresh posts are less likely to rank high in search results.

Now how do you disable comments in Blogger for old posts because unlike WordPress, there are now AutoShutOff and Comment Timeout plugins for blogger? The answer is simple - use Javascript.

<script type="text/javascript" language="javascript1.2">
var shutoffperiod = "2" // Turn Off Period (in months)
var str = "<$BlogItemPermalinkURL$>";

var year = str.split("/")[3];
var month = str.split("/")[4];
var d = new Date();


var diff = (d.getFullYear() - year)*12 + d.getMonth() + 1 - month;


if (diff <= shutoffperiod) {
document.write('<a href="http://www.blogger.com/comment.g?');
document.write('blogID=1234&postID=<$BlogItemNumber$>">Comment</a>');
} // Replace 1234 with your Blog ID 
</script>


All you have to do is replace your Post a Comment blog in the blogger template with the above code. It computes the date of the blog post from the permalink and depending on the age of the blog post, the "Post a Comment" link will be added to your blog post.


Remember to replace 1234 with your Blog ID. The comment posting link for visitors is hidden by default for blog posts that older than 2 months. You can modify the default setting by changing the value of shutoffperiod variable in the script.


Related: Add Visitor Comments Policy in Blogger

Popular posts from this blog

How to Download Contacts from Facebook To Outlook Address Book

Facebook users are not too pleased with the "walled garden" approach of Facebook. The reason is simple - while you can easily import your Outlook address book and GMail contacts into Facebook, the reverse path is closed. There's no "official" way to export your Facebook friends email addresses or contact phone numbers out as a CSV file so that you can sync the contacts data with Outlook, GMail or your BlackBerry. Some third-party Facebook hacks like "Facebook Sync" (for Mac) and "Facebook Downloader" (for Windows) did allow you to download your Facebook friends' names, emails, mobile phone number and profile photo to the desktop but they were quickly removed for violation of Facebook Terms of Use. How to Download Contacts from Facebook There are still some options to take Friends data outside the walls of Facebook wall. Facebook offers the Takeout option allowing you to download all Facebook data locally to the disk (include

PhishTank Detects Phishing Websites by Digg Style Voting

OpenDNS, a free service that helps anyone surf the Internet faster with a simple DNS tweak , will announce PhishTank today. PhishTank is a free public database of phishing URLs where anyone can submit their phishes via email or through the website. The submissions are verified by the other community members who then vote for the suspected site. This is such a neat idea as sites can be categorized just based on user feedback without even having to manually verify each and every submission. PhishTank employs the "feedback loop" mechanism where users will be kept updated with the status' of the phish they submit either via email alerts or a personal RSS feed . Naturally, once the PhishTank databases grows, other sites can harness the data using open APIs which will remain free. OpenDNS would also use this data to improve their existing phishing detection algorithms which are already very impressive and efficient. PhishTank | PhishTank Blog [Thanks Allison] Related: Google

Digital Inspiration

Digital Inspiration is a popular tech blog by  Amit Agarwal . Our popular Google Scripts include  Gmail Mail Merge  (send personalized emails with Gmail ),  Document Studio (generate PDFs from Google Forms ) and   File Upload Forms ( receive files  in Google Drive). Also see  Reverse Image Mobile Search , Online Speech Recognition and Website Screenshots , the most useful websites on the Internet.