It's not so hard to implement your own. You just send request to the server when an event happens like: tracker.gif?action=create&what=sth
, tracker.gif?action=error&what=k_is_undefined
, etc.
Then you parse the server logs for the stats. (or you send your request right into the database by tracker.php?action=create&what=sth
)
Since you control the site it's now easy to make these requests when a user logs in, or an ajax request fails.
For error handling you can use window.onerror
:
// send a request about an event to the server
function fireEvent(action, message, options) {
var loggerUrl = "/tracker.gif", parameters;
options = options || {};
options.url = options.url || window.location.href;
options.user_agent = navigator.userAgent;
options.message = message;
for (var i in options) {
if (options.hasOwnProperty(i)) {
parameters += "&" + i + "=" + encodeURIComponent(options[i]);
}
}
new Image().src = loggerUrl + parameters;
}
// log script errors
window.onerror = function(errorMessage, url, line) {
fireEvent("error", errorMessage, {
url: url,
line: line
});
return true;
};
// example event on the page
fireEvent("ajaxError", "XY page failed to load");
(note: window.onerror
is not available in safari)
UPDATE
And here is a proof of concept for a PHP parser:
$i = 1;
$d = file_get_contents("log.txt");
$requests = explode("\n", $d);
foreach ($requests as $req) {
$pos = strpos($req, "tracker.gif");
if ($pos === false) continue;
$start_pos = strpos($req, "?", $pos);
$end_pos = strpos($req, " ", $start_pos); // can also be " HTTP"
$length = $end_pos - $start_pos;
$req = substr($req, $start_pos+1, $length);
$exprs = explode("&", $req);
echo $i . ".<br>"; // request number
$i += 1;
foreach ($exprs as $expr) {
list($name, $value) = explode("=", $expr);
echo $name . " =>" . $value . "<br>"; // key => value
}
}