This part displays local banners and counts the views and clicks just fine.
This part displays the HTML snips like affiliate codes and such which are complete tags from elsewhere.
Code:
else { echo $adtext; }
The ads display just fine. Counts views for both types of ads using the SHOW fucntion.
Code:
if ($action == "show") { $query = "SELECT * FROM $banners WHERE id = $id"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); $link = $row['link']; if (strtolower(substr($link,0,5)) != "http:") $link = "http://" . $link; $today = date("d m Y"); $query = "SELECT * FROM $stats WHERE date_format(banner_date, '%d %m %Y') = '$today' AND id = $id"; $result = mysql_query($query) or die(mysql_error()); $num_results = mysql_num_rows($result); $today = date("Y-m-d"); $query = "UPDATE $stats SET clicks = clicks + 1 WHERE id = $id AND banner_date = '$today'"; $result = mysql_query($query) or die(mysql_error()); header("Location: ".$link); }
What I need is to count the CLICKS for the HTML snip codes.
The
Code:
$adtext;
displays the ads fine pulling from the database but will NOT count the clicks. I know it is because I can not call the SHOW function to increase the clicks like I do with local banners.
While going crazy I tried this to insure I am in the right place.
Which is NOT correct I know... BUT if I click on the number 1 displayed with this code it increments the clicks by one. Mainly because I am calling the SHOW function.
I need a way to either call the SHOW function for the ads that are pulled and displayed using $adtext or another function that can be used to do the same thing to count clicks.
Any help on this matter would be greatly appreciated! I also hope I am making sense here... Like I said, my brain is gone!
Global Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6691
34714 credits Members referred : 374
It's time to use PHP5!
« Reply #1 on: Nov 05, 2008, 11:44:51 am »
I get you right that you need to count the impression of text ads?
Atari ST fan
Posts: 8
52 credits Members referred : 0
« Reply #2 on: Nov 05, 2008, 01:46:07 pm »
Hello Olaf, No. They are standard ads just in a snippet. If you take a look at the code I included you can see that my script does the following two things.
1. Tracks views and clicks of local banner ads where I input the banner link, image and so on. 2. Tracks views of affiliate code type banner ads like from Commission Junction, Link Share and the like.
I need it to be able to track the HTML snippet banner ads.
Right now it just grabs the whole affiliate code and displays the banner. It then tracks the views for the affiliate banner.
It is called using $adtext;
Since it doesn't use the banner.php code to call the SHOW function it does NOT count the clicks for these ads.
I need a way, function, class of something to call something simular to the SHOW function so it will increment the clicks as well.
Does this explain better?
I am a metal monkey!
Administrator Community Supporter?
Jedai Sword Master
Gender:
Posts: 5799
46391 credits Members referred : 3
« Reply #3 on: Nov 05, 2008, 01:56:50 pm »
Where do you keep the html snippets? Aren't they on the database?
Global Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6691
34714 credits Members referred : 374
It's time to use PHP5!
« Reply #4 on: Nov 05, 2008, 02:11:09 pm »
you can count clicks two ways:
redirect the URL with a script or get clicks with javascript and a click count script
Atari ST fan
Posts: 8
52 credits Members referred : 0
« Reply #5 on: Nov 05, 2008, 02:17:53 pm »
Hello Nikolas, yes the snippets are stored in the MySQL database.
In short, I have a form to add, edit and so forth for new banners. I have a choice of either LOCAL banners where I add link, image and so on. on the same form, is a textarea for adding affiliate codes like Link Share and such.
Both are stored in the database and called from it.
This calls the SHOW function which increment the clicks.
The HTML snippets is called with an echo tag, like this:
Code:
echo $adtext;
It then pulls from the database and displays on the page. It will count the views since it pulls from the database.
But unlike the local banners, it does not use the banner.php script to call thr SHOW function to increment.
I need a way to have it count the clicks on the ADTEXT banners as well... Since it doesn't use the SHOW function and basically just pulls the code from the database and displays it.
« Last Edit: Nov 05, 2008, 02:26:12 pm by DonH »
Atari ST fan
Posts: 8
52 credits Members referred : 0
« Reply #6 on: Nov 05, 2008, 02:21:49 pm »
Olaf, I don't think I am making myself clear to you.
It already counts views and clicks on local banners. It counts views for snippet banners but doesn't for clicks as it pulls the snippet from the database and displays it.
It will count the clicks if I can figure out a function, class or something to have it do something like the SHOW function to increment the clicks.
Atari ST fan
Posts: 8
52 credits Members referred : 0
« Reply #7 on: Nov 05, 2008, 02:33:24 pm »
If I do this, it counts everything. Increments both views and clicks because I'm just making it do with this code as there is no separation of views and clicks. No SHOW function to separate the views from the clicks.
But maybe it will show everyone what I am trying to say and do.
Here's the code that doesn't work right for obvious reasons.
Code:
if ($adtype == 1) { echo "<a href=\"$site_url/banner.php?id=".$id."&action=show\" target=\"$target_text\" onFocus=\"this.blur()\"><img border=\"$border\" style=\"border-color: $border_color\" src=\"$site_url/$image\" title=\"$alt\" alt=\"$alt\"></a>"; } else { $query = "SELECT * FROM $banners WHERE id = $id"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); $adtext = $row['adtext']; $today = date("d m Y"); $query = "SELECT * FROM $stats WHERE date_format(ezban_date, '%d %m %Y') = '$today' AND id = $id"; $result = mysql_query($query) or die(mysql_error()); $num_results = mysql_num_rows($result); $today = date("Y-m-d"); $query = "UPDATE $stats SET clicks = clicks + 1 WHERE id = $id AND ezban_date = '$today'"; $result = mysql_query($query) or die(mysql_error()); echo $adtext; } }
As you can see. IF it's a local banner it use the SHOW function. ELSE it displays the ADTEXT.
« Last Edit: Nov 05, 2008, 02:35:00 pm by DonH »
Global Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6691
34714 credits Members referred : 374
It's time to use PHP5!
« Reply #8 on: Nov 05, 2008, 02:46:30 pm »
maybe you should post an example snippet at this point
Atari ST fan
Posts: 8
52 credits Members referred : 0
« Reply #9 on: Nov 05, 2008, 02:57:49 pm »
Hello, ok here's what a standard snippet or HTML code looks like.
As you can see, it's a standard banner tag. This is what it pulls from the database and displays it on the page.
It is called using the echo tag of $adtext;
Unlike the local banners that use a tag that also calls the SHOW function to increment the clicks... This one only displays the code.
If I use this code
Code:
if ($adtext == "$adtext") { $query = "SELECT * FROM $banners WHERE id = $id"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); $adtext = $row['adtext']; $today = date("d m Y"); $query = "SELECT * FROM $stats WHERE date_format(ezban_date, '%d %m %Y') = '$today' AND id = $id"; $result = mysql_query($query) or die(mysql_error()); $num_results = mysql_num_rows($result); $today = date("Y-m-d"); $query = "UPDATE $stats SET clicks = clicks + 1 WHERE id = $id AND ezban_date = '$today'"; $result = mysql_query($query) or die(mysql_error()); }
It will increment both VIEW and CLICKS for the HTML code snippet... Which is not correct. But the idea of needing a function, class or something to trigger a process to only count clicks when it is actually clicked on...
Making more sense yet?
« Last Edit: Nov 05, 2008, 02:59:25 pm by DonH »
Global Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6691
34714 credits Members referred : 374
It's time to use PHP5!
« Reply #10 on: Nov 05, 2008, 03:18:38 pm »
you need some javascript/ajax code to do this (or you need to change the snippets)