Almost every website operator wants search engine spiders to visit. After all, search engines are the best source of free traffic on the web. In the event that you don’t want them to visit, they are easily kept at bay with a properly formatted “robots.txt” file.
Unfortunately, there’s another group of spiders out there crawling the web, with an entirely different purpose. These are the spiders that visit site after site, collecting email addresses. You may know them as spam bots, email harvesters, or any number of unpublishable names.
When it comes to controlling these rogue spiders, robots.txt simply won’t get the job done. In fact, most spam robots will ignore robots.txt. That doesn’t mean you have to give up, and just let them have their way. In this short tutorial, I’ll teach you how to hide your email addresses from them.
Technique #1:
Use Javascript To Mask Email Addresses
One of the weaknesses that spiders of all kinds suffer from is an inability to process scripts. Adding a small snippet of Javascript in place of an email address effectively renders the address invisible to spiders, while leaving it accessible to your visitors with all but the most primitive web browsers.
In the three examples below, simply substitute your username (the first half of your email address, everything before the @ symbol) and your hostname (everything after the @ symbol). To use the scripts, just insert them into your page’s HTML wherever you need them to be displayed.
Example 1: Creating A Spam-Proof Mailto Link
This snippet of code creates a clickable link that launches the visitor’s email application, assuming that their system is configured to work with mailto links. You can replace the link text with your own message, but see example 2 if you want to display your email address as the link text.
- <script language=javascript> <!– var username = “username”; var hostname = “yourdomain.com”; var linktext = “Click Here To Send Me Email”; document.write(“<a href=” + “mail” + “tox” + username + “@” + hostname + “>” + linktext + “</a>”) //–> </script>
Example 2: A Spam-Proof Mailto Link With Your Email Address Showing
Some visitors won’t be able to use a mailto link, and will instead need to read the email address. No problem, just use the snippet below instead.
- <script language=javascript> <!– var username = “username”; var hostname = “yourdomain.com”; var linktext = username + “@” + hostname; document.write(“<a href=” + “mail” + “tox” + username + “@” + hostname + “>” + linktext + “</a>”) //–> </script>
Example 3: Display Your Email Address Without A Mailto Link
Sometimes, you just want to give your email address without making it a clickable link – here’s a snippet that accomplishes just that:
- <script language=javascript> <!– var username = “username”; var hostname = “yourdomain.com”; var linktext = username + “@” + hostname; document.write(username + “@” + hostname) //–> </script>
Technique #2:
Hide Behind A Contact Form
Sometimes the sheer volume of email from real visitors can become a burden. In this case, a simple solution is to remove your email address from your site entirely, and use a contact form. There are dozens of free ASP, Perl, and PHP scripts available online that will allow your users to fill in a form, and send you an email. Many hosting providers offer this service for free to their customers.
A contact form can enable you to deal with a higher volume of mail by allowing you to pre-sort different types of messages. This is easily accomplished by creating a drop-down menu with different options (e.g. customer service, billing, tech support, etc.) that will populate the subject line of the email message.
I hope that this tutorial has given you a clear understanding of how to protect your website, and your email address, from spam-bots. If you have any questions about this article, feel free to contact me through my website. The (spam-proof) email link is at the bottom of my home page, right after the “P.S.”
I wish you success…
Dan Thies is a well-known writer and teacher on search engine marketing. He offers consulting, training, and coaching for webmasters, business owners, SEO/SEM consultants, and other marketing professionals through his company, SEO Research Labs. His next online class will be a link building clinic beginning March 22