404 Tech Support

Resetting Webpage Stats in Joomla Mod_Stats

I’m pretty spread out across different CMS’s these days: Joomla, Drupal, and obviously WordPress. I’m hoping to remove Joomla by migrating sites to Drupal or WordPress. Today, I received a request to reset the default stat counter for a Joomla-powered site. The hit counter that comes with Joomla is mod_stats and includes mod_stats.php and helper.php. The front-end of mod_stats allows you to tweak some settings of the hit counter but doesn’t allow you to zero it out in case you want to track by the year. My normal approach would be to implement a better tool like Google Analytics but since I’m hopefully changing the site soon, I looked into just resetting the counter.

By running through the code with mod_stats, I figured out its query and was able to reset the counter. I was expecting a simple value in the database keeping track of the traffic. Instead, there is an attribute in the Content table called ‘hits’. It keeps track of the visitors to each page. The stat counter then sums all of those values together from each article and outputs it wherever you have the Stats module set.

Using phpMyAdmin which comes with most shared hosting these days, I was able to find the table and use an SQL query to zero out the hits value of all articles.

[sql]UPDATE `[JoomlaTablePrefix]_content`
SET `hits` = 0[/sql]

Change the [JoomlaTablePrefix] to whatever your database table prefix is, obviously. If you don’t know the database username and password needed to get into database, you can look in your site’s configuration.php and find the information there.

After I zeroed the hits on all of the articles, it took a little while for the stats to show up again. As soon as it registered a new visitor though, it showed up again where it was placed in the theme. Hopefully I’ll be away from Joomla this time next year but in case I’m not, I now have it documented how to “easily” reset mod_stats to zero.