Drupal module Usage Data (Statistics), a possible replacement for Drupal core's Statistics module
The Usage Data Drupal module is intended for internal site analytics, treating page views, clicks, and downloads as events recorded to a table, possibly replacing Drupal core's Statistics module. Learn more about and get the module here: https://www.drupal.org/project/usage_data.
Features
- A pluggable system to allow endless tracking abilities based on any event
- A default "Generic" plugin that will track the most common page views from:
- Node
- Media
- Taxonomy Terms
- Commerce Products
- Routes
- Views Pages
- JS-triggered tracking for click events (View README)
- Custom Data Structures
- Queue support to prevent DB stampeding (use via Redis, etc)
- Track Downloads via hook_download()
Version 1 and View Database Connector module
For version 1, this module can work better with the Views Database Connector module. You can then pull your data out by integrating this or by writing your custom queries. You can add columns to the usage_data table by writing your install hook (hook_install()) in a custom module.
See the README for the default table structure. Project module page here: https://www.drupal.org/project/views_database_connector.
How to configure and use
As this involves querying from the database, developer support is needed. This module is not for the non-technical Drupal user.
- Install and enable
- Go to the module settings /admin/config/system/usage-data
- .htaccess alteration
For this module to work, you need to allow the custom controller in your .htaccess. Below the Statistics module's rule add a similar condition:RewriteCond %{REQUEST_URI} !/modules/contrib/usage_data/usage_data\.php$ - To do this, open and edit your .htaccess, and find the core Statistics rewrite condition (example for D9):
RewriteCond %{REQUEST_URI} !/core/modules/statistics/statistics\.php$ - Below that insert the provided Rewrite condition for Usage Data provided above, save .htaccess, and upload; flush Drupal cache if needed
- Exclude (or include) any user roles from tracking (e.g. select all roles except Anonymous if you only need to track website usage from an anonymous public frontend)
- For version 2, enable plugins and queuing to process items as needed. Usage-type plugins are used to create specific tracking tables for whatever needs you may have. Plugins can define what is tracked and additional table schema if needed to store additional data.
- You may create a Views, pull Usage Data plugins values, and configure as needed


