Forum Moderators: coopster & phranque

Message Too Old, No Replies

Need script to count outgoing hits

cgi script - outgoing hits

         

davewray

10:00 pm on Jul 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi all. I was wondering if there was a cgi/perl script that I could add to my directory to determine how many visitors are leaving through certain links? What I would like is some type of program that would add one increment to a counter by each listing every time that specific listing is clicked on. If you can help, that would be great! Thanks :)

Dave.

sugarkane

9:18 am on Jul 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There's quite a number of free scripts around that do this with varying degrees of sophistication, but a simple click counter is easy enough to implement yourself.

#!/usr/bin/perl

use CGI;
$query=CGI::new();
$url=$query->param("url");

open (FP, ">>clicks.log");
print FP "$url\n";
close(FP);

print "Location: $url\n\n";

If you link to this script in the form <a href="script.cgi?url=http://www.webmasterworld.com">foo</a> it'll log that click and then redirect to the url specified.

Counting the clicks would then be a matter of checking how many times each url shows up in the log file.

davewray

3:03 pm on Jul 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Sugarkane, thanks for the reply. But what I was really looking for was not a script that would send the number of clicks to a log somewhere, where I"d then have to count them up. What I was thinking of was a script that would automatically increment a number beside the directory listing each time it was clicked. For example: Listing number 1: http:**//www.widgetsanon.com (Added June 4, 2003; 5 hits). Then, if this listing was clicked on again, that number would automatically increment up to "6" without any further intervention or searching through logs from me. Is this possible? Thanks! :)

Dave.

davewray

4:57 am on Jul 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Does anybody have a script to do this? :)