I wish there was some way to see ads on my site, but not have them count as impressions. It would make sense for webmasters, and Google would benefit too since we all make more money when ad relevancy is optimized.
if you have a static IP .. yes it helps.. yeah.. a really good article. I like the idea of adding the extra code for testing.
where bouts does tht code go exactly? isit just above the adsense script? thnks for tht tip was lookin for summin like tht
<? // tells getip() if one of the ips it detects is valid or not. function validip($ip) { if (!empty($ip) && ip2long($ip)!=-1) {// reserved IANA IPv4 addresses // http://www.iana.org/assignments/ipv4-address-space $reserved_ips = array ( array('0.0.0.0','2.255.255.255'), array('10.0.0.0','10.255.255.255'), array('127.0.0.0','127.255.255.255'), array('169.254.0.0','169.254.255.255'), array('172.16.0.0','172.31.255.255'), array('192.0.2.0','192.0.2.255'), array('192.168.0.0','192.168.255.255'), array('255.255.255.0','255.255.255.255')); foreach ($reserved_ips as $r) { $min = ip2long($r[0]); $max = ip2long($r[1]); if ((ip2long($ip) >= $min) && (ip2long($ip) <= $max)) return false; } return true; } else return false; } // detects the user's ip function getip() { global $HTTP_SERVER_VARS; if (validip($HTTP_SERVER_VARS['HTTP_CLIENT_IP'])) return $HTTP_SERVER_VARS['HTTP_CLIENT_IP']; elseif ($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR']!="") { $forwarded=str_replace(",","",$HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR']); $forwarded_array=split(" ",$forwarded); foreach($forwarded_array as $value) if (validip($value)) return $value; } return $HTTP_SERVER_VARS['REMOTE_ADDR']; } function ShowAdsense() { // return 1; // uncomment this in order to see ads no matter what ip detects. $detectedip = getip(); // repeat this block, only changing $testip if you have several ip's $testip="127.0.0.1"; if (substr($detectedip,0,strlen($testip))==$testip) return 0; $testip="87.100.3."; // <-- works on ip ranges if (substr($detectedip,0,strlen($testip))==$testip) return 0; return 1; } ?> PHP: I'm using the code above, it's placed in a php file which is connected to the other php files using the include or require_once statement. You can then use : if (showAdsense()==1) { // show the ad } PHP: It's a bit more complex because I have two or three different IP classes and I'm actually blocking an IP class ( see the second block in ShowAdsense )