Software to track link use

Mark Ellis mark.ellis at rpl.richmond.bc.ca
Tue Oct 8 13:54:31 EDT 1996


Grace,

We've addressed this problem using the Perl script below.

Look at http://www.rpl.richmond.bc.ca/asian/Hongkong.html to see how the
links are done.

This approach has some costs associated with it though. You would need to
change all your external links to call the script and users of those links
will experience some delay as their browsers hit your server, run the
script, and are redirected to the real destination.  Follow some of the
links on the Hong Kong page above to see what it's like.

This script will artifically inflate your log file with hits that would
normally only appear in someone else's log.

This is not intended as a turn-key solution, just a start in the right
redirection. :-)

<SNIP>----------------------------------------------------------------------
-----
# redirect.pl
# &re_direct( location ): redirects browser to a new URL

chdir ('/website/data/wwwrpl/cgi-bin/');

$curlog = "redirect.log";

# $delim = record delimiter
# $field_sep = field separator
#
$delim = "\n";
$field_sep = "\t";

# Code to produce string which is date and time
($sec, $min, $hour, $mday, $mon, $year) = localtime( time );
$mday = '0' . $mday if (length( $mday ) < 2);
$TimeOnly = sprintf("%02d:%02d:%02d", $hour, $min, $sec);
$month = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)[$mon];
$DateOnly = $mday."/".$month."/"."19".$year;
$tzone = "-0800";
$logdate ="[".$DateOnly.":".$TimeOnly." ".$tzone."]";

# Redirect the browser to URL passed in the query string
#

&re_direct( $ENV{'QUERY_STRING'} );


# Output the form to the log, with fields separated by $field_sep and
# records delimited by $delim
#
open( FILE, ">>$curlog" );
print FILE $ENV{'REMOTE_ADDR'}, $field_sep, $ENV{'HTTP_REFERER'},
$field_sep, $logdate, $field_sep, $ENV{'QUERY_STRING'}, $delim;

close( FILE );

# re_direct( $location )
# This sub redirects the browser to the URL given in $location
#
sub re_direct {
local ($location) = @_;
print <<"--end--";
HTTP/1.0 301 Redirect
MIME-version: 1.0
Content-type: text/html
Location: $location

<h1>301 Redirect</h1>
Document is located at <a href="$location">$location</a>
--end--
}

</SNIP>---------------------------------------------------------------------
----------

>I hope you will bear with me while I try to describe what I'm looking
>for.  I maintain a collection of web resource pages which users within
>the organization can access from their desktops using the Netscape
>Personal Edition or from an x-terminal in the library.  I have been asked
>to identify those links on the resource pages that are being used most
>frequently.  The links are all external.
>        The systems administrator does not know of any program that can
>capture this type of activity.  If anyone knows of a program that can
>accomplish this at the server level, please let me know.  User surveys
>have been tried in the past, and the response has been extremely poor.
>Installing software on the user's pc is not an option.
>        Please reply to me personally.  Thanks.
>
>                Grace Garbe, MLS
>                Garcia Consulting, Inc.
>E-Mail: ggarbe at uspto.gov

----------------------------------------------------------------------------
Mark Ellis
Computer Services Technician            Phone: 604.231.6410
Richmond Public Library                 Email: mark.ellis at rpl.richmond.bc.ca
Richmond, British Columbia
----------------------------------------------------------------------------




More information about the Web4lib mailing list