[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cobalt-users] Tracking URL Click Thru's
- Subject: Re: [cobalt-users] Tracking URL Click Thru's
- From: "Steven Werby" <steven-lists@xxxxxxxxxxxx>
- Date: Sat Mar 25 08:42:08 2000
Tim Lajoie <admin@xxxxxxxxxxxxx> wrote:
> I want to be able to produce stats for the number of times visitors click
on
> a spcific url on our site.
If you are referring to a link to an external URL you'll have to do some
work to capture it.
> My understanding is that I have to use a CGI script in conjunction with
the
> url to produce a log file entry when the visitor clicks on the url.
This is easily done with a simple PHP script that logs the clickthrus to a
MySQL table (or a text file if you prefer).
There's more to the code, but here is the guts of it:
// This is what links look like
echo "<a
href="?url_to_1=www.domain.com&url_to_2=/index.html">www.domain.com</a>";
// This creates a row in the MySQL table
$sql = "INSERT INTO clickthru VALUES ";
$sql .= "('$SERVER_NAME', '$SCRIPT_NAME', '$url_to_1', '$url_to_2', ";
$sql .= "'$REMOTE_ADDR', '$REMOTE_HOST', now());";
// This redirects the browser to the desired link
if (isset($url_to_1) && empty($url_to_2)) {
header("Location: http://$url_to_1"); }
elseif (isset($url_to_1) && isset($url_to_2)) {
header("Location: http://$url_to_1.$url_to_2"); }
This creates a table with that captures the following:
my website, my webpage, destination website, destination webpage, user IP,
user host, time/data
Of course, if you just want to increment the count of clickthrus for a given
URL the code would be simpler and the MySQL table would be much smaller
since there'd only be one row for each URL instead of one row for each
clickthrough. If PHP/MySQL is an option for you and you'd like I can send
you the full code from a working page.
Steven {steven@xxxxxxxxxxxx}