ShortStat Beta
Update
A new version of ShortStat is now available.
Until recently I’ve been completely satisfied using Reinvigorate’s Data Archiving Services to keep track of referrers and daily hits. DAS was ideal for previous versions of this site (basically one page loading content into an iframe): add a link to an external javascript file to the homepage and almost all traffic coming into the site gets recorded. But with the transition to Moveable Type comes the possibility of readers bypassing the front door and going straight to the content. So DAS no longer cuts it.
Now I’m sure there are hundreds of free, robust PHP/MySQL stats packages out there but what do I do? I decide to roll my own (check out /shortstat/
off of root for a sample)—with all that free time I have. The code is coarse but it gets the job done and covers some bases that even DAS misses:
- keeps a running total of referrals from individual domains
- recognizes that all IE 5s are not created equal—and that there never was a Netscape 5
- records the number of hits individual resources receive
- mosty importantly, is coded from scratch so I can add more functionality as desired
On the off chance that this meager solution appeals to somebody else, I’ve zipped it up with simple instructions for use and an installer for the single database table required. It is provided strictly on an as is basis. You are soley responsible and liable for any damage you do to your website or server. Okay, it’s really not that scary but I had to say it.
Download ShortStat v0.2b.
Note
Adding ShortStat code to a custom 404 page tracks missing resources but does not make any distinction between a 404 and an existing resource. This can be useful if you watch your resources closely and can recognize potential 404s. Otherwise it just pollutes your numbers. I hope to work out a fix for this soon.
Another Note
It’s been brought to my attention that accessing ShortStat from shortstat.yourdomain.com
instead of yourdomain.com/shortstat/
will result in yourdomain.com
appearing excessively in your list of referrers. ShortStat should not display your domain at all in either list of referrers. I made the incorrect assumption that $_SERVER["HTTP_HOST"]
would contain the main domain minus the subdomain.This will be addressed in the next release. To correct it in the current version just open functions.php and change $_SERVER["HTTP_HOST"]
to $_SERVER["SERVER_NAME"]
on lines 242 and 266.
024 Comments
I have installed ShortStat on my server . Works great!
Would be more useful for me if can track the countries or search engine keywords.
Thank you Inman!
I’ll have to look into figuring out country info but the search engine keywords is a great idea and should be pretty easy to implement. A future version of ShortStat will probably use a couple of database tables to cut down on redundancy in the main table. Thanks for the feedback SK.
This is just what I’ve been looking for - particularly one that breaks down browser usage properly. My current site stats just do one big ‘Netscape 5.0’!
Thanks Shaun, I’m off to install this little beauty!
…Well that was painless! I’m a very happy chap.
Great script Shaun!
I can’t wait to see what comes of it!
i second the idea to show search keywords
great job though, painless to install, and it actually looks nice
hi shaun, i’ve installed your short stat, its only working when i actually go into the inc.stats file right now -but i’ll figure it out
great job :D
The inc.stat.php (and any files that it is included in) must be included using a relative path (as opposed to the full domain with
\"http://\"
). Otherwise, your server and not the visitor’s browser is the requesting user agent and referrer. That’s why trackme.php and the installation instructions use$_SERVER[\"DOCUMENT_ROOT\"]
to include inc.stats.php.Could this be causing the problem you described Steven?
Thank you for this great script!
Could you use
$db[\"server\"]
instead of$db[server]
(and of course all other arrays), because i get a lot of errors, when i don’t change it.To clean up your code, you can add the following lines to your code:
ERROR_REPORTING(E_ALL); ini_set(\"display_errors\",\"1\");
Again, thanks for this great script.
Oh, btw: preg_match is faster than eregi. :
Thanks Shaun, its working sweetly now…
again you have my praise :D
Sorry to be the annoying one, but php is not my forte. I have set up a new database, have a working username and password… but the install can’t access my database. I have checked my username, password, and database name a thousand times. They are correct. I can access the database directly through my browser (through PHPMyAdmin). So, I can only assume that my server name is wrong. I have tried “localhost” and also the subdomain I have created “example.jasonsantamaria.com”. No dice. Is anyone else on Dreamhost out there? I guess I am too busy rolling around naked in my piles of graphic designer money with many groupies (what can I say, girls still go wild for the Bauhaus movement) to learn more about this PHP tomfoolery. Regardless, once again Shaun, have some more smoke up your ass, this thing looks slick.
Wow!! Great piece of program…thankx for the opportunity.
I’m addicted. I’ll make my daily visits here…to enjoy, be educated. :)
Hi Jason,
I am with dreamhost (though the server I mentioned in my first post is not dreamhost, but I have installed ShortStat on my other dreamhost site), for the server name, it should be your mysql subdomain, (eg, mysql.yourdomain.com). Hope this will help.
By the way, I am addicted monitoring my ShortStat. Cool to see some spider/crawler around my site.
Thanks again, Shaun!
Jason, you can keep the smoke—but how ‘bout sharing the wealth?
If SK’s suggestion doesn’t work and you have access to your phpMyAdmin config.inc.php file look for
$cfgServers[1]['host']
(around line 40). Your$db[server]
value should have the same value. If neither are successful I don’t know what to try. My PHP/MySQL experience has been rather sheltered. I’ve had all of two hosts who both had the same set-up as far as I can tell. Sorry, I can’t offer more.Danilo, my associative arrays will be quoted in the next release. SK & AK, keywords are partially done. Which search engines should I accomodate? They all use different query string variable names. So far I’ve added support for Google (all international flavors) and Yahoo. MSN? AOL probably, huh?
Wow, just a day old, new features will be added. Great job, Shaun!
Personally, I ‘ll be happy with just Google and Yahoo. But the more the merrier, can track what other search engines used by other folks.
The addition of new features is easy enough as is a brand new installer. The difficulty lies in creating an updater for people who currently have v0.2b installed. I’ve worked out the country tracking code but it requires an additional 1.7MB ip-to-country lookup table that can be a real pain to install depending on your host’s set-up so I’m going to make it an optional feature.
Shaun-
This is great! Took me about five minutes to install, and it works beautifully. Love it!
Thanks!
Hey SK, would you have time to email me and hold my hand for a moment with this? Since you are on Dreamhost as well…
[email protected]
Not to be picky, but I was just thinking it would be nice to see the hits from the past five days or so.
I’ve also been watching the progress on your site and it looks sweet!
That’s not being picky, I want something like that too. I was thinking about breaking out each days stats individually but I haven’t figured out a MySQL query that does it elegantly enough yet. Expect that in a future version.
I released ShortStat Beta 3 this morning which incorporates many of the early requests made in this thread (sorry Michael - no daily breakdowns yet).
I’m known as quite lazy. I’d always been planning on making my own stats program (a much more simple one), but never got around to doing it. Thanks Shaun, I’ll install this as soon as some problems on my server are fixed…
I can’t seem to get my shortstat to install. The database is not created when I call the _install.php file from my browser. I’ve looked through the comments, but I can’t seem to find a reference to this problem. Has this problem already been addressed?