jStats allows you to aggregate statistics about visitors on your site, without breaking the cache-ability of your pages.

At its core, jStats could be seen as a bridge between the core Statistics module, that stores its data in Drupal but is incompatible with aggressive and external caching, and Google Analytics, that only adds a small JS fragment to the page and thus makes them perfectly cachable, but can't easily be accessed by Drupal modules (in order for example to sort a listing of node by the number of node views): it's a lightweight way to keep your statistic data in your database, that still works when the page you want to have statistics on is stored in cache.

jStats also allows you to track the number of "recent" views on a page, where recent can be configured to whatever you want in the UI. This is usefull if you want to have blocks listing only the most viewed nodes in for example the last hour or the last two days, and is a variation on core Statistics module that only gives the total number of node views and the number of views since midnight.

Which means that you probably only really want this module if:

  • Your site is hosted behind a reverse proxy that deals with pretty much all of the anonymous page views
  • You want to use those statistics directly from a module, for example as a Sort criteria for a view.
  • You want a "most viewed recently" block where you need to finetune what recently means.

In terms of performance, jStats is optimized for high traffic sites :

  • The callback only bootstraps drupal at the database level and inserts a record in a log table
  • The aggregation of those log entries is handled asynchronously via cron

If you want to cache your page for a long time, but needs to have some blocks that should have a shorter cache lifetime (for example, you want to cache the whole page for 2 hours, but have an "Hot news" block that shouldn't be older than 5 minutes), have a look at the following modules:

jStats is sponsored by Radio France and OWS, and has been deployed there on huge production sites for 2 years.

Supporting organizations: 
Funded initial development

Project information

Releases