Training, Open Source computer languages

PerlPHPPythonMySQLhttpd / TomcatTclRubyJavaC and C++LinuxCSS

Search our site for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
What brings people to my web site?
How busy is your web site? How do people find it? Where do they arrive from? If you have access to your log files and they're using the "combined" format that tells you about the referer, you'll have that information - but hidden deeply in what's likely to be a huge file.

Here's a little bit of PHP code that you could put at the top of a page that you're particularly interested in tracking; it'll let you keep a log of how many visits you get from where, maintaining a very simple data file that you can look at from time to time, and reset when you want to start counting again.


<?php

/* Page to report keep tabs of all the various referers */

/* Find the referer */

$whence = $_SERVER[HTTP_REFERER];
if (! $whence) $whence = "-";

$previous = file("reflist.txt");
$repeat = 0;

// If this is a previously know referer, add 1 to the count

for ($k=0; $k $wl = explode(" ",$previous[$k]);
if ($wl[0] == $whence) {
$ncount = $wl[1] + 1;
$previous[$k] = "$whence $ncount\n";
$repeat = 1;
}
}

// If this is a new referer, add it to the know list

if (! $repeat) {
array_push($previous,"$whence 1\n");
$ncount = 1;
}

// Save the new counts

$fh = fopen("reflist.txt","w");
fputs ($fh,implode("",$previous));
fclose($fh);

// Send out the response page (sample)

?>

<body>
<h1>Headline information
This is visit number <?= $ncount ?> from <?= $whence ?><br>
<a href=/demo/fromwhere.php>Reload linking from here</a><br><br>
<h2>Full information ...</h2>
<?= join("<br>",$previous) ?>
</body>


You may Access the demo from here
(written 2005-07-13 06:16:14)

 
Associated topics are indexed under
H112 - PHP - Further Web Page and Network Handling
A606 - Web Application Deployment - Apache - log files and log file tools
G902 - Well House Consultants - Web site techniques, utility and visibility

Back to
Oops - I got my initial database design wrong
Previous and next
or
Horse's mouth home
Forward to
A Strengthened City

Some other Articles
Bridging to the customer requirement
Getting the lighting right
A word of admiration for the London cabbie
A Strengthened City
What brings people to my web site?
Oops - I got my initial database design wrong
Instant availability
Vik, Iceland to Melksham, England
Time calculation in PHP
The training team that's looking out for you
1636 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

© WELL HOUSE CONSULTANTS LTD., 2008: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho