Weblog posts ranked by popularity
Olivier asks if there’s a Movable Type plugin that lets you rank posts by popularity, based on referrer stats
. Since his “email me” link is stuffed, I’ll answer here: yes, several, with different approaches, including at least one more that I couldn’t find.
It’s really a very good idea, offering a new visitor who came in via a permalink your very best posts, rather than just the previous (“My cat threw up on the bed”) and the next (“Gym class still suxs”) and one that I’d like to see done by more than just uber-geek MT users who can figure out how to parse their Apache access logs. For example, Blogger’s bStats app knows which URLs are permalinks (the ones with anchors), and how often they’ve been requested, by the day, week, month, or year, so it wouldn’t be that hard for them to combine that data with your weblog data to make a <BloggerTopPosts> container where BlogItemPermalink (forthcoming, I hope) and BlogItemTitle work, to produce a list of the top ten or fifteen posts for whatever period you choose. Same for Textbox and TypePad and the Radio Community Server (where I’d be inclined to make it available as an RSS feed).
But back to Movable Type and Apache access logs: the two solutions I found were from currybetdotnet, which publishes a list of all your archive links and titles, then uses that as a key for a Perl script to look through your access log, producing a file that can be SSI/PHP included, and from hackdiary, which parses the access log looking for URLs that include the entry ID number (oops, maybe I shouldn’t have gone to titles for archive URLs), uses the XML-RPC API to look up the title from the entry ID, creates an RSS file from that, and then uses a plugin to parse the RSS file when the main page is rebuilt.
The hackdiary solution is lots of fun, using RSS and the API, but it requires entry IDs in your individual entry archive URLs, and only changes when you rebuild, so including it on archive pages (where I think it’s most useful, to hang onto someone who came in from a link to a particular post) would either require a ton of rebuilding, or a script to dynamically include an RSS file. The currybet.net solution is a lot simpler and more flexible, if you are already using SSI or PHP, since you can then include the list anywhere you want. However, it requires another index template using <MTArchiveList>, which as anyone hosted somewhere that hates Movable Type (like DreamHost) knows is the biggest killer of rebuilds. I’m sure I saw another one somewhere, that didn’t seem quite as painful as either one of those, but it seems not to have used any of the search keywords that are coming to me right now. Got any idea where it was?
(Hrm. Occurs to me that my referrals script has been gathering up exactly that data for months, though I may not have made it very easy to get it back out cheaply.)
Inspired by this, I hacked together a script that uses the cache files from AWStats (just like my referers plugin does).
The main problem is that my top posts aren’t that interesting! They’re just pages that people have found via Google that rank well for random keywords, e.g. Rate my rack.
I’ll tidy it up tonight and post it if anyone else is interested.