Various advertising networks strictly prohibit publishers from clicking on contextual ads appearing on their own website. Multiple clicks and impression arising from a few IP address may lead to ban your account. Many publishers have been banned from Google AdSense program because of this. Accidental clicks result while you work on your website for eiditing and modifying and while viewing preview of edited version. Therefore it is very useful to protect yourself form accidental clicks. Changing the hosts file is one of the best ways which permanently remove appearance of contextual ads from chosen places (like Google, Chitika etc).
Typically a “hosts” file contains only one entry that is “127.0.0.1 localhost” (see picture below) . In simple layman language, a host can be any website and the hostname always points to a particular unique IP address. In above case localhost is hostname for your computer and it will point to IP 127.0.0.1. IP address and hostname in combination recognize the web presence of any website. AdSense and other contextual ads arise from a particular server (hostnames) which points to a particular IP. Every computer recognizes this unique IPs. If you assign your computer’s IP address (127.0.0.1) for each of hosts serving ads in your website then your computer will point to your IP (127.0.0.1). This will prevent retrieval of actual ads from AdSense, Chitika and other advertising network servers in your computer. Now next thing is how to change the “hosts” file. Just go to C:\WINDOWS\system32\drivers\etc. Now click on the file named “hosts” with notepad. Now you can add the “IP Address – Hostname” combinations to block ads from various contextual advertising services. Here IP address will always be “127.0.0.1” while hostname will vary depending on where from your ads appearing on your websites. First write IP “127.0.0.1” followed by “hostname” after giving 2 spaces. Add only one entry per line. This setting will permanently blocks AdSense, Chitika and other specified ads from appearing on your computer web browser. Therefore there is no questions of invalid clicks.
For your convenience, I have listed the recommended setting which you can add to your “hosts” file.
Set common IP ( 127.0.0.1) for all hosts.
- Hostnames to serve Google ads
127.0.0.1 adwords.google.com #[Gmail ads]
127.0.0.1 pagead2.googlesyndication.com #[Google AdWords]
127.0.0.1 www.google-analytics.com #[Google Analytics]
- Hostnames to serve Chitika ads
127.0.0.1 ads.chitika.net #[IE-SpyAd]
Source: Article first published in Blogger’s Magazine.