|
|
|
12-15-1999, 02:17 PM
|
Postid: 43454
|
|
Registered User
Join Date: May 1999
Posts: 242
|
PHP banner rotation script
I've already written banner rotation/tracking scripts using PHP3/MySQL for pages on my site. Recently I joined an affiliate program where my "payment" for referrals is advertising space, which I intend to sell. I get to define the HTML for the advertising. If I wanted to include the same ad on all the pages the HTML would be something like:
Code Sample:
I'd like to rotate in several ads and I'd like to integrate it with the same banner rotation/tracking system I use for the pages on my site. Basically, I want to define some HTML that will access a PHP script on my site to get the URL of the banner graphic and the URL of the like. Is there a way to do that?
Thanks,
Paul
|
|
|
12-16-1999, 12:23 AM
|
Postid: 43455
|
|
Visitor
Join Date: Aug 1999
Posts: 19
|
Instead of using a .gif extension for the banner graphic, you can use a .php3 file. For example:
<A SRC=" http://www.mysite.com?adID=x">
<IMG SRC=" http://www.mysite.com/banner.php3?adID=x">
</A>
Then the source of banner.php3 would be:
<?php
## do stuff interacting with the mySQL database
## to decide which banner to send seeing as how
## $adID = x
header("Location: $bannerurl\n\n"  ;
?>
So in that example, if $bannerurl was " http://www.amazon.com/banner123.gif", when someone loaded a web page that included banner.php3 as an inline image, in actuality, amazon's banner would come into place.
Does that solve it?
|
|
|
12-16-1999, 08:41 AM
|
Postid: 43456
|
|
Registered User
Join Date: May 1999
Posts: 242
|
Thanks Patrick. That solves half of it. header("Location: $bannerurl\n\n"  ; is what I need to rotate the graphic. But I also need to be able to change the URL that the banner links to. In <A HREF=" http://www.mysite.com?adID=x"> I need to be able to set x to correspond with the graphic displayed so that when someone clicks through I know which advertiser's site to go to. Any ideas?
|
|
|
12-16-1999, 01:49 PM
|
Postid: 43457
|
|
Visitor
Join Date: Aug 1999
Posts: 19
|
Actually you could do something very similar with the link as you did with the banner: You could use
<A SRC=" http://www.mysite.com/redirectit.php3?adID=x">
<IMG SRC=" http://www.mysite.com/banner.php3?adID=x">
</A>
redirectit.php3 would be like this:
===
<?php
### do stuff with mySQL table to determine
## value of $pagetosendclickerto based on th
## knowledge that $adID = x
header("Location: $pagetosendclickerto\n\n"  ;
?>
A drawback to this is that you cannot change the which advertiser is associated with $adID = x too frequently, because every time you do, there will be a situation where people load up the banner advertising advertiser 1 (Amazon) and when they click they will be sent to advertiser 2 (barnesandnoble.com). Because the significance of $adID = x will have been rotated. However, if you only change the which advertiser is associated with $adID = x rarely, once a week maybe, that might not be much of a drawback.
|
|
|
12-16-1999, 02:47 PM
|
Postid: 43458
|
|
Registered User
Join Date: May 1999
Posts: 242
|
The drawback mentioned is exactly the problem I am trying to get around. How can the PHP script that is called when a visitor clicks know which site to redirect to if the banner is changed on each page view?
I know there is a way to do it because several months ago I registered with ValueClick. They give you static HTML you insert into you web pages which rotates ads and somehow knows which advertisers site to go to when you click on a particular banner. Here's the code (h0072566) is my ValueClick ID#):
Code Sample:
<A TARGET="_top" HREF="http://www62.valueclick.com/cgi-bin/redirect?host=h0072566>
<IMG SRC=http://www62.valueclick.com/cgi-bin/cycle?host=h0072566>
</A>
|
|
Hmmm, I just thought of a rather archaic way to do it. In the script that determines which ad to display, I could store the IP address of the visitor and the adID in a table. Then the script that does the redirection could use the IP address of the visitor to look up the last ad displayed to the visitor and redirect to that advertisers site. This method fails, however, if the visitor clicks on an ad that isn't the last one shown to him. For example if he has two browser windows open or uses the back button.
Any ideas anyone?
|
|
|
12-16-1999, 05:34 PM
|
Postid: 43459
|
|
Visitor
Join Date: Jan 1999
Location: Kissimmee, FL
Posts: 3,672
|
Most banner scripts just output the HTML for the banner and the link...
...
print "<a href="whatever"><img src="whatever"></a>";
...
Usually this requires SSI or PHP Include, however, you can do this in Javascript if your banner ad script can output something like this:
...
print "document.write ('<a href=\"whatever\"><img src=\"whatever\"></a>');";
...
Then, where you want the banner, put something like this:
...
<script language=JavaScript src="/path/to/banner/script.pl">
...
The advantage to this method is that you can use this type of banner script accross domains/servers/sites - because in SSI you can't give a full URL, but JS src can be a full URL.
Also, of course, you can use this in standard HTML pages, PHP, Perl generated pages, or whatever (you could put the JS line in the UBB header, for example).
I thought of this method a while back and am considering rewriting my Perl banner ad script to allow for being called via JavaScript (only has to be modified to print the "document.write" parts)...
Hope this helps...
------------------
Justin Nelson
FutureQuest Support
|
|
|
12-20-1999, 04:02 PM
|
Postid: 43460
|
|
Visitor
Join Date: Aug 1999
Posts: 19
|
Here's what to do, Paul. Have JavaScript write code A into pages where you want the banner and link to show up for JS enabled browsers, but noscript write code B into pages where you want the banner and link to show up for NON JS enabled browsers.
Code A calls for
... .php?timepast=718930
as the banner graphic and
.php?timepast=718930
as the click-through link.
Inside your mysql tables, store that 718930 associated with that IP address belongs to a clickthrough to amazon.com
However if the person clicks to another page on the site, the javascript will force a new appending or "timepast" value, as well as forcing a new page to be loaded:
now
.php?timepast=718947
as the graphic is a barnesandnoble.com banner
and anyone clicking on
.php?timepast=718947
as the link will ask the mysql database "which page should ip address 101.202.19.23 be redirected to if timepast=718947" and it will say
"barnesandnoble.com", **** you!
|
|
|
12-20-1999, 04:05 PM
|
Postid: 43461
|
|
Visitor
Join Date: Aug 1999
Posts: 19
|
I forgot to mention, that in cases where there is a NON javascript enabled browser, maybe you could just have an "ad of the day" that would only be rotated once per day. That way only people clicking on your banners between 5am and 5:10am would be redirected incorrectly.
funny my expletive was ****ing deleted. i will use them more god **** frequently from now on!!!
|
|
|
01-13-2000, 03:18 PM
|
Postid: 43462
|
|
Registered User
Join Date: May 1999
Posts: 242
|
Just in case anyone else is interested, I found the solution . I came across the ad rotation/tracking software at http://phpwizard.net/phpAds/ It does exactly what I want. I should have thought of this before, but the trick to linking to the right URL when rotating several banners is to have the script that selects the banner to be shown set a cookie with the bannerID. Then when the viewer clicks on the ad, the click processing script knows what URL to go to be reading the cookie.
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 visitors)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 08:52 PM.
|
| |
|
|
|