Tracking ad google adsense

Discussion in 'PHP' started by newevolution, Sep 13, 2009.

  1. #1
    Welcome

    He writes a little script that will track clicks on the ads and also secured a double click. I wrote two tables I added to the principal called the "ad" on the link in the ad code. Please help me how to make accounted clicks.

    if (!empty($_GET['visit']))
    {
    	$ad = $_GET['visit'];
    	$source = mysql_query("SELECT * FROM ad WHERE aID='$ad'") or die(mysql_error());
    	$num_rows = mysql_num_rows($source);
    	if ($num_rows < 1) {
    		echo "Sorry, ad id not found in database";
    		mysql_close($link);
    		}
    		else
    		{
    			$source = mysql_query("SELECT * FROM ad where aID='$ad'") or die(mysql_error());
    			while($row = mysql_fetch_array( $source )) {
    				$type = $row['type'];
    			}
    			if($type == "tradedoubler")
    			{
    				$source = mysql_query("SELECT * FROM new where adId='$ad' and IP='$usrip'") or die(mysql_error());
    				$num_rows = mysql_num_rows($source);
    					if ($num_rows >= 1) {
    						mysql_close($conn);
    						echo "";
    						}
    						else
    						{
    				$source = mysql_query("SELECT * FROM ad WHERE aID='$ad'") or die(mysql_error());
    				while($row = mysql_fetch_array( $source )) {
    				$link = $row['link'];
    						}
    				mysql_query("INSERT INTO new (`adId`, `IP`,`click`) VALUES ('" . $ad . "', '".$usrip."', '1');") or die(mysql_error());
    				mysql_close($conn);
    				@header("location:$link");
    				}
    			}
    PHP:
    I found this http://www.icemelon.com/tutorials/17/Track_Google_Adsense_Clicks.htm but something is not working please help
     
    newevolution, Sep 13, 2009 IP
  2. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I wouldn't run that code if I were you, it's subject to sql injections (google it).
     
    matthewrobertbell, Sep 13, 2009 IP
  3. dreteh

    dreteh Member

    Messages:
    514
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    33
    #3
    Or at least use mysql_real_escape_string() to prevent sql injections.
     
    dreteh, Sep 16, 2009 IP
  4. Stat_jack

    Stat_jack Active Member

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    56
    #4
    AGree Google Devolves are skilled these days
     
    Stat_jack, Sep 18, 2009 IP
  5. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Doesn't google analytics now allow you to track adsense? Haven't used it myself, but you should check it out.
     
    premiumscripts, Sep 18, 2009 IP
  6. pneulameiro

    pneulameiro Peon

    Messages:
    440
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Yes, google analytics tracks adsense gains. But if you are using wordpress, or joomla, or any other cms then it is propable that you can find a plugin to do this.
     
    pneulameiro, Sep 18, 2009 IP
  7. newevolution

    newevolution Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Can be done on the same php tracking ads ?
    How do I track of ad ?
     
    newevolution, Sep 19, 2009 IP
  8. kapesnik

    kapesnik Well-Known Member

    Messages:
    154
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    111
    #8
    kapesnik, Sep 23, 2009 IP