Page 1 of 1
Hit script
Posted: Fri Sep 24, 2004 1:28 pm
by Archy
I am trying to make a script that a user signs up for an affiliate scheme. Once signed up, (s)he gets a unique number. Then, I am using this number to collect the impressions (s)he gets (hits), and also the clicks (click through rate) the link recieves. I can collect the clicks easily, there is no problem there, but is there a way in which I can make the hits increment.
Obviously I dont want to give them a PHP script with connect etc, and also the usernames and passwords. Although this information could be encypted (still a risk of them brute forcing it) but also, people who sign up for the affiliate scheme may not have PHP enabled on their server.
So, can anyone think of a way in which every impression the image/link gets, the database will increment accordingly. I suppose this is kind of like the Google Adsense way, in which you give them a code etc.
Thanks.
Posted: Fri Sep 24, 2004 1:31 pm
by ldomingues
You can have a script in your server which collects clicks.
For instance: You give to your affiliate a link like:
http://www.yourserver.com/click.php?affiliate=100
When a use clicks on the affiliate site, he gets redirected to
http://www.yourserver.com/click.php?affiliate=100, and you put that in a DB/file, etc.
Posted: Fri Sep 24, 2004 1:37 pm
by Archy
I can make the clicks increment perfectly, just the trouble of collecting the impressions of the image/link will get is the tricky bit.
Posted: Fri Sep 24, 2004 1:46 pm
by ldomingues
You must code your links.
As to the images, you can create a php script which will count the hit and then passthrough the image file.
All images had to be coded like <img src="yoursite.com/get_image.php?file=logo.gif">
Posted: Fri Sep 24, 2004 1:51 pm
by Archy
Im still not really clear on hos to do this though :\
Posted: Fri Sep 24, 2004 1:51 pm
by ldomingues
It's more clear now... You want to track link impressions, not link clicks.
Option 1) use a ad server application - phpaddsnew works greate
Option 2) if the customer has php support (or any other language), he has to include a php script (hosted on your server) which in turn will generate the link and count the impression
Option 3) no php support - use javascript which is returned by a php script on your server
Example:
Your server has generatelink.php - which returns:
<script>
document.write("yourlink");
</script>
To include a link the user includes one or more javascript files (which are in reality php scripts which return javascript).
Look in detail phpaddsnew - it does something like this.
Posted: Fri Sep 24, 2004 1:53 pm
by ldomingues
Another note: This can hog your server easily! Your server must be fast enough to track impressions for:
number of affilitates x number of sites x number of online users on each site x number of links in each page being viewed !!!
Posted: Fri Sep 24, 2004 2:02 pm
by Archy
Hmm, I was kinda hoping it would be a reasonably simple script, I dont really want to use third party software as I have coded the whole of the site now except for this. All I need is a script to increment a hit counter in a MySQL database from images on external sites.
Posted: Fri Sep 24, 2004 2:10 pm
by ldomingues
I'm just suggesting to take a look to phpaddsnew, and see how it works.
You can get very good ideas from this script - it's OpenSource and written in PHP.
Posted: Fri Sep 24, 2004 2:44 pm
by Archy
I downloaded, I looked, I couldnt find the code the client uses :\
If there is a easier way to make the script (than having to sift throgh 752 files) then I would be interested

Posted: Fri Sep 24, 2004 3:04 pm
by ldomingues
feyd | Please use Code: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Here is the generated JavaScript code to output one banner:
Code: Select all
<script language='JavaScript' type='text/javascript'>
<!--
if (!document.phpAds_used) document.phpAds_used = ',';
phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
document.write ("http://adserver/adserver/adjs.php?n=" + phpAds_random);
document.write ("&what=zone:1&target=_blank&blockcampaign=1");
document.write ("&exclude=" + document.phpAds_used);
if (document.referer)
document.write ("&referer=" + escape(document.referer));
document.write ("'><" + "/script>");
//-->
</script>
feyd | Please use Code: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Posted: Fri Sep 24, 2004 4:17 pm
by Archy
Would this be what I wanted, as from the looks of it, will it not display a random banner?
Posted: Fri Sep 24, 2004 4:19 pm
by feyd
why not try it, and find out?
Posted: Fri Sep 24, 2004 5:12 pm
by Archy
Hmm, it was tricky to implament as I had to change a bit of it, but it didnt work : (
Basically, it was a complete failure on my behalf :\
Posted: Sun Sep 26, 2004 5:59 pm
by Archy
Anyone got any ideas on how I could do this, as I still havent figured out how to do it.