I've used the bbclone stats package for a while now and it pretty much does exactly what I want. It is, however, pretty much geared towards PHP driven websites or static HTML sites. Getting it working nicely with typo (or any other rails app for that matter) seems to be a little trickier. The hacky (and probably temporary) solution I've come up with involves a hidden iframe on every typo generated page that links to the PHP script below:
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s")
. " GMT");
header("Cache-Control: no-store, no-cache, "
."must-revalidate");
header("Cache-Control: post-check=0, pre-check=0",
false);
header("Pragma: no-cache");
define("_BBC_PAGE_NAME", $_GET['page']);
define("_BBCLONE_DIR", "/full/path/to/bbclone/dir/");
define("COUNTER", _BBCLONE_DIR."mark_page.php");
if (is_readable(COUNTER)) include_once(COUNTER);
?>
The markup for the iframe looks like this and is added to the bottom of the default.rhtml file in your current theme:
1 2 |
<iframe frameborder="0" scrolling="no" width="0" height="0" src="/bbclone_hit.php?page=<%=h params %>"> </iframe> |
Passing <%=h params %> as the page name is, I admit, pretty lame - I'll fix that later. At least I can now see some stats!