Making money fast online with the internet: The honest truth.
It ain't easy!!
How do you block Google Adsense adverts appearing for certain IP addresses on your HTML website?
A common request amongst Adsense publishers is the need to stop Google Adverts appearing when you web pages are served up to particular external IP addresses. Reasons for this are mixed. If you happen to maintain your websites from a computer on an internet connection that has a fixed IP address, then you may well wish to suppress Ads when you are viewing your site to avoid accidental clicks or excessive page impressions – especially if you have a forum.
If you use Adsense at work, no matter how many times you tell your colleagues or boss “do not click the ads”, this is too tempting for most people, and the odd rogue click squeaks through, wrecking your standing with Google.
If you are doing a lot of updates and visits to your site you might end up skewing your statistics for that day because of the sheer number of impressions you create.
Alternatively, you might find that a spammer is doing excessive clicks on your adverts, trying to discredit your site – if you could block their IP address from viewing adverts, this would be very useful.
Whilst this trick can be accomplished using various scripting languages, if you are working in just HTML and do not use PHP or ASP etc, the easiest way of blocking particular IP addresses from creating Adsense impressions and preventing visitors from a certain IP address viewing or clicking on your adds is to use SSI, server side includes.
SSI is a very crude server side scripting language available on IIS and apache web servers (i.e. most of them!)
For example, if you put this in an HTML page (you might need to use shtml extension or turn on ssi for html in your htaccess file)
<!--#include virtual="menu.txt"-->
When the web page is sent to the user, this line is replaced by the contents of the menu.txt file. This makes it very easy to keen your left nav in one file that is referenced on one page.
How do we use SSI to block Google Adsense to certain IP addresses? The IP address of the client can be accessed by the SSI language.
First, you create a text file and put your google Adsense code in it. Call it Adverts.txt or similar. Just paste in the code from the Adsense website, and wrap it with any formatting you desire
Never change the Adsense code – always use exactly what google gives you.
Put this adverts.txt file onto your website next to your html page. In the html page, remove the ads code and replace it with
<!--#include virtual="adverts.txt"-->
Upload the changes to your website... and you will not notice. The server inserts the adverts.txt file into the HTML before anything gets to your browser.
Now we put a bit more SSI code around the include statement.
<!--#if expr="$REMOTE_ADDR!=61.62.63.55" -->
<!--#include virtual="adverts.txt"-->
<!--#endif -->
Now if you visit your website from the address 61.62.63.55 you will not see the adverts – the SSI script will only include the adverts.txt file if you come from an IP address other than the one specified.
This is how you stop specific IP addresses from seeing your Google Adsense adverts and clicking on them. Final point: Because you are not modifying the adsense code, you are not breaching any terms and conditions of Google. In fact, it is unlikely they will know you are doing it!