Are you looking for basic page view analytics for a Drupal site? You do not need the complexity of Google Analytics, and you definitely do not want to show visitors yet another cookie consent popup? Or maybe you value user privacy and prefer not to feed large tech corporations with behavioral data.
In all of these cases, I built a module for you.
Page Analytics provides simple, server-side page view analytics for Drupal, presented as clear charts and reports directly in the admin panel. No JavaScript tracking is required, which means no cookie banners and no privacy policy gymnastics. There are no third-party services involved, so you do not need to create accounts on external SaaS platforms or manage API keys. All results are stored directly in Drupal’s database.
Usage
Install and enable the module as usual.
composer require 'drupal/page_analytics:^1.0@beta'
drush en page_analyticsTo start seeing data in the report, simply visit a few front-end pages. If the “Exclude logged-in users” option is enabled, make sure to visit them as an anonymous user. Then run cron. Why cron? More on that below.
You can find the report under Reports » Page analytics. There you will see a list of the most visited paths, each with a total view count and a chart showing daily visits over a selected time range (last week or last month). This makes it easy to spot overall volume, trends, and traffic peaks across your site.
The module also provides a configuration screen under Administration » Configuration » System » Page analytics, where you can fine-tune performance-related settings and, if needed, clear the collected analytics data.
Performance and how it works
Page Analytics records daily page view metrics with no noticeable impact on page rendering time. Thanks to a sampling mechanism and the use of Drupal’s Queue API, the module avoids doing work on every page request. Also, actual database writes do not happen during page requests at all, but only during cron runs.
Here is how it works under the hood:
On each successful (HTTP 200) response for a given path, the module records only a random, configurable fraction of page views.
- Eligible page views are added to a Drupal queue.
- When cron runs, a queue worker upserts records into the database table using the path and date as the key, incrementing the view count accordingly.
- The worker processes up to 100 items per cron run and applies the configured sampling rate when estimating total views.
- The report reads data from the database, and older rows are automatically removed during cron runs based on the configured retention period.
This approach keeps runtime overhead low while still providing meaningful, actionable insights.
Comparison with other modules
Drupal core (up to version 10) includes the Statistics module, which serves a similar purpose but offers a much more limited feature set. Below is a comparison between the core Statistics module, Page Analytics, and Google Tag–based solutions:
| Statistic | Page Analytics | Google Tag | |
|---|---|---|---|
| Where tracking runs | Server-side (PHP) | Server-side (PHP) | Client-side (JS) |
| Available statistics | Low - total views and today only | Medium - daily counts shown as charts | High - enterprise-grade stats, charts and tools |
| Entry level | Low - plug-and-play, simple to use | Low - plug-and-play, simple to use | High - configuration both on the Google and Drupal sides, complicated to use |
| Privacy | High - no private data collected | High - no private data collected | Low - Full user tracking |
| Ownership of data | High - all stats inside your private database | High - all stats inside your private database | Low - stats are stored on an external platform |
Available configuration
- Sampling rate (1 in N)
Defines the fraction of recorded page views (for example, 3 means 1 out of every 3 views is sampled). This helps reduce queue size and database writes on high-traffic sites. The report displays estimated totals. Higher values improve performance at the cost of accuracy. Use 1 for exact counts. - Keep data for (days)
Specifies how long analytics data should be retained. Rows older than the configured number of days are automatically deleted during cron runs. - Excluding criteria
Exclude admin paths, certain roles or certain paths from being counted.
Drush
The module includes a Drush command useful for debugging and fine-tuning settings
drush page-analytics:status(alias:drush past) — Shows queue size, table row count, last cron run, and current config.
Development status
The module is available for Drupal 11 and is currently in beta, ready for community testing. It also awaits the security advisory coverage application. I encourage you to try it out. If you notice any issues or come up with ideas for new features, feel free to open an issue on the module’s project page. Feedback and contributions are always welcome.