Whilst browsing the bbPress forums last week I noticed someone requesting a plugin to show hit counts. Now as the author of Simple View Counts I thought I would step and offer my link. But it turns out the OP had already seen my plugin but descided not to use it because WordPress was warning that my plugin was unmaintained and hadn’t been updated for two years! The latter part was true, but the plugin still worked as described – it didn’t need any updates.
But it gets worse, apparently after this arbitrary two year gap in updates WordPress will de-list the plugin from the public directory! Not cool.
So, that’s a lesson to any plugin authors, you have to make some change every two years, even if your plugin is so well written it doesn’t need maintenance!
But anyway, I had always intended to add a few features, so why not take this opportunity. I hate the idea of just changing something around just for the sake of forcing an update out, I wanted to make it better…
I had a request for Simple View Counts to track how many members had read any given post. Now tracking unique views is a tricky challenge, how do you define a unique visitor in WordPress (turns out there is no inbuilt mechanism for this). However, tracking unique members is easy enough. Every logged in user will have a UserID which is simple enough to record against a post.
<?php $user_ID = get_current_user_id(); ?>
Plugin users now have the option to choose whether they want to track hit counts (literally every time the page is loaded, no matter who does it) or member count. The latter will only increase on the first view by a logged in user. So if your website only has 10 members, the count will only show a maximum of 10. This seems particularly effective in a private forum, but it’s a good indicator of engagement in a public forum – you can see if logged in users are actually viewing your post or is it all just passing Google traffic.
I now feel inspired to add more to this little plugin:
- Whilst I don’t want to track unique visitors, can I prevent the view count increasing when a reader hits F5 repeatedly. For example by using the transient cache to track IPs for the length of a session. Crude, but would work.
- I’d like to offer more options for positioning the counts:
- Replace voice count
- More prominent on the topic pages
- Introduce a widget to show the most viewed post from the last x number of days.
- Perhaps an admin stats page too, so if you don’t want a public widget admins can still see which posts are attracting attention.
Any other ideas?