Millwood Online

My views on the Drupal Statistics module

Back in January I opened an issue "Remove Statistics module from D8 core", this was around the same time I was working on Project Verity. We wanted a page where the content creator can go and see site statistics, latests content, latest comments etc. It was soon found that relying on the statistics module in Drupal Core was not the best way forward for this so we started working with the Google Analytics API, although this is another story.

This all sparked my interest in the statistics module, what it should do and how it should work. Last month another issue about the statistics module in core popped up "Improve statistics module for D8?". Last week within DrupalCon CHX wrote a blog post about "The Drupal 8 action plan" which featured the statistics module as one of the modules in core that he would like to see "the imminent death of".

I agree with CHX, I would like to see "the imminent death of" the statistics module too, although I feel there needs to be something for statistics in Drupal Core. Therefore I also agree with the "Improve statistics module for D8?" issue thread too.

Here it what I would like to see:-

  • A core module for tracking many different aspects of a page request.
  • Javascript based interaction to work with varnish and similar caching.
  • Able to interact with local or remote data sources
  • Rules, settings and attributes to allow control of statistics gathering
  • Views integration to display statistics

My personal next step would be to remove the statistics module and start an initiative to rewrite the module from the ground up.

The first steps for the new module would be to define a new hook, maybe hook_statistics. This hook would be called at every page load and passed details / statistics about the page being loaded and machine loading it via Javascript / AJAX. Many modules could then use hook_statistics to save this data to the local database or any datasource.

I would love to hear some thoughts on this, and will therefore cross post in the issue queue.