Mostly Harmless

Adding Slimstat to WordPress  

by Jan Dembowski on Saturday May 26th, 2007 at 7:55 am

Slimstat thumbI run this web site as a hobby but I still like to have tools to check how the site is doing. Slimstat is a tool that I use because it captures things like search strings, referers, etc. It’s like Google analytics but more local.

For WordPress there is a useful plugin that adds Slimstat to the dashboard. My advice to people is to use the plugin as it is fire and forget.

I don’t listen to my own advice :-) so I prefer to add Slimstat outside of Wordpress by adding a few lines to the wp-config.php like so:

// Jan added Slimstat
$ip_jan=$_SERVER['REMOTE_ADDR'];
$url_ref=@$_SERVER['HTTP_REFERER'];
if (($ip_jan != "24.46.186.255" ) or ($ip_jan != "64.233.178.136")) {
if (!(preg_match("/translate.google.com/",$url_ref))) {
@include_once( "/srv/www/slimstat/inc.stats.php" );
}
}
/* That's all, stop editing! Happy blogging. */

I am not a programmer and my PHP is horrible. I add the code to wp-config.php because it gets included every time and I don’t have to modify the theme. Putting it there also means when I upgrade the theme or WordPress version it will get preserved from being overwritten.

I put the if statements in there because I want to exclude from logging website requests from a Google address and from my own IP address. I use Angsuman’s translator plugin and exclude anything that is refered from translator.google.com. If someone hits a web page with /post-slug/es/ (for the spanish version) then I want to see that URL and not the ones that the machine translator hit.

Setting up Slimstat is easy as pie. I put the slimstat on a HTTPS portion of my web page, used .htaccess to password protect the URL (for no real reason other than I can) and I get easy stats available to me without logging into Wordpress.

Related posts:

  1. Translator plugin problems
  2. Machine translation in WordPress
  3. Wordpress SSL Admin plugin (patched)
  4. Adding numbers to post titles in WordPress
  5. All is good with WordPress 2.5

The article has

3 responses

Posted in Software

Tagged with ,

3 Responses to 'Adding Slimstat to WordPress'

Subscribe to comments with RSS or TrackBack to 'Adding Slimstat to WordPress'.

Leave a Reply