Never accidentally click your own ads again

Discussion in 'AdSense' started by alejandro, Sep 20, 2007.

  1. #1
    As we all know, clicking your own ads can be a problem. People start using other programs or tools to eliminate this, but here is another easy solution.

    Note: You can use whatever filenames you want, but my example will use the filenames I use.

    If using PHP:

    Start by creating a file called exclude.php. Place this in a folder in the root directory called 'includes'.

    The code in exclude.php should look like this:

    <?
    if (getenv(HTTP_X_FORWARDED_FOR)) {							
        $ip = getenv(HTTP_X_FORWARDED_FOR); 
    } else { 
        $ip = getenv(REMOTE_ADDR);
    }
    
    $array[0] = "xxx.xxx.xxx.xxx";
    $array[1] = "xxx.xxx.xxx.xxx";
    $array[2] = "xxx.xxx.xxx.xxx";
    
    $adexclude = "false";
    
    foreach($array as $value)
    {
    	if($value == $ip)
    	{
    		$adexclude = "true";
    	}
    }
    ?>
    Code (markup):
    The xxx.xxx.xxx.xxx will be replaced with the IP addresses that you commonly view your site from. Increase the number in the $array[X] for each IP.

    Add this code to each page, or your template page, right after the <HTML> tag:

    <?
    ini_set ("include_path", ini_get ("include_path") . ':../:../../:../../../:../../../../');
    include('includes/exclude.php');
    ?>
    Code (markup):
    Add this code around your AdSense code:

    <?
    if($adexclude == "true")
    {
    ?>
                Display this instead 
    <?
    } else {
    ?>
                GOOGLE ADSENSE CODE 
    <?
    }
    ?>
    Code (markup):
    Replace GOOGLE ADSENSE CODE with, surprise, surprise, your AdSense code.

    If your IPs are setup correctly, when you view your pages, your Ads will now display 'Display this instead' to you, not your code. To everyone else, the Ads will show. Now you never have to be careful on your sites again!

    I have the code for ASP as well... somewhere... if I find it I will post it.
     
    alejandro, Sep 20, 2007 IP
  2. tripy

    tripy Guest

    Messages:
    32
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Or you could install adBlock for firefox and add adsense to the filter, and you won't ever see those ads
     
    tripy, Sep 20, 2007 IP
  3. navjotjsingh

    navjotjsingh Well-Known Member

    Messages:
    640
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    125
    #3
    Adblock Extension or any adblocker tool is much better than use scripts and tools to prevent clicking.

    But anyways nice script though.
     
    navjotjsingh, Sep 20, 2007 IP
  4. myclip

    myclip Peon

    Messages:
    595
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    i think navjotjsingh is right, use the regular tool rather than abnormal one
     
    myclip, Sep 20, 2007 IP
  5. wierdo

    wierdo Well-Known Member

    Messages:
    1,646
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    140
    #5
    Nice simple but effective script. I agree with navjotjsingh though.
     
    wierdo, Sep 20, 2007 IP
  6. Adulu

    Adulu Peon

    Messages:
    2,791
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #6
    thank you

    It's really a good one
     
    Adulu, Sep 20, 2007 IP
  7. totalmasala

    totalmasala Banned

    Messages:
    1,454
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I have blocked adsense ads on my Internet network!
     
    totalmasala, Sep 20, 2007 IP
  8. trichnosis

    trichnosis Prominent Member

    Messages:
    13,785
    Likes Received:
    333
    Best Answers:
    0
    Trophy Points:
    300
    #8
    the tip that you mention is good but adsense team has made an official blog post about this.

    accidental clicks may happen from time to time. if you are not cliking your own ads, accidental clicks is not a problem for this
     
    trichnosis, Sep 20, 2007 IP
  9. alejandro

    alejandro Active Member

    Messages:
    328
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    80
    #9
    True, accidental clicks happen, but you can reduce them to 0.
     
    alejandro, Sep 21, 2007 IP
  10. Whitey

    Whitey Active Member

    Messages:
    1,386
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    80
    #10
    How will the script know that it's YOUR IP's? Wouldnt it just add anyones IP? :p
     
    Whitey, Sep 21, 2007 IP
  11. indianz

    indianz Active Member

    Messages:
    201
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #11
    im using adblog for firefox is better
     
    indianz, Sep 21, 2007 IP
  12. writingman1421

    writingman1421 Active Member

    Messages:
    211
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #12
    Accidents happen, but theres software to prevent you from clicking on your own adsense links? Is that really necessary?

    I am not expert on this, but it would seem to me that you would just NOT click on the links. Maybe once by accident, but I fail to see the reason for a script or software for this problem....is it really that big of a widespread problem?
     
    writingman1421, Sep 21, 2007 IP
  13. Trabzonlu

    Trabzonlu Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    its very nice for me thx
     
    Trabzonlu, Sep 21, 2007 IP
  14. mindiam1

    mindiam1 Well-Known Member

    Messages:
    1,190
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    128
    #14
    What about if you use a proxy in your browser, which thousands of other people use, how can google track this?
     
    mindiam1, Sep 21, 2007 IP
  15. tradeya

    tradeya Notable Member

    Messages:
    5,729
    Likes Received:
    275
    Best Answers:
    0
    Trophy Points:
    230
    #15
    dont worry mate, they are smarter than you think. They can track from the logs, stats, etc and check the behaviour of the visitors. if you know what i mean. ;)
     
    tradeya, Sep 22, 2007 IP
  16. alejandro

    alejandro Active Member

    Messages:
    328
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    80
    #16
    You add the IP's manually. It does not automatically add them for you.
     
    alejandro, Sep 25, 2007 IP