If you're building with Drupal 11 and want flexible, modern page view tracking, you may have noticed that the version of the Statistics Counter module on Drupal.org is only compatible with Drupal 10. Fortunately, a Drupal 11–ready version is now available for free on GitHub, offering enhanced architecture, modern PHP practices, and seamless integration with Drupal's event and service systems.
What Is the Statistics Counter Module for Drupal 11?
This enhanced version of the Statistics Counter module is built specifically for Drupal 11 and is not available on Drupal.org. It provides a developer-focused foundation for tracking node views using Symfony Event Subscribers and Drupal’s service container.
Unlike the Drupal 10 version, this fork or reimplementation supports the latest changes in Drupal 11, offering better long-term support and adherence to modern best practices.
Key Features
- Drupal 11 Compatibility: Fully updated to work with Drupal 11 core and PHP 8.2+.
- Event-Driven View Tracking: Listens for node view events via
StatisticsCounterSubscriber.php. - Views Integration: Use
statistics_counter.views.incto display view counts in Drupal Views. - Service-Based Architecture: Clean
statistics_counter.services.ymlfor dependency injection and overrides. - Modern Composer Support: Easily integrated into your Composer workflow.
- Free and Open Source: Download from GitHub, licensed under GPL.
How It Differs from the Drupal.org Version
| Feature | Drupal.org Version | GitHub Version |
|---|---|---|
| Drupal 11 Compatibility | ❌ No | ✅ Yes |
| Event Subscriber Support | ❌ Limited | ✅ Full |
| Modern PHP Practices | ❌ Older | ✅ PSR-4, Symfony |
| Maintainer | Community | idflorin |
| Download Location | Drupal.org | GitHub |
Note: If you’re running Drupal 11, do not install the Drupal.org version—it may not function properly or even install cleanly.
Installation Instructions
Clone the module into your custom modules directory:
git clone https://github.com/idflorin/statistics_counter.git web/modules/custom/statistics_counterEnable the core Statistics module:
drush en statisticsEnable the Statistics Counter module:
drush en statistics_counter- Customize the
StatisticsCounterSubscriber.phpfile to define your custom logic. - Use Drupal Views to display and sort content by view count.
Use Case Ideas
- Trigger Events Based on View Count: Alert or flag content when it crosses a threshold.
- Highlight Popular Content: Show “Top Articles This Week” using Views.
Final Thoughts
The GitHub-hosted version of the Statistics Counter module is a must-have for Drupal 11 developers who need customizable, reliable, and modern content view tracking.
Unlike the outdated Drupal.org version, this implementation embraces Drupal 11’s architectural improvements—like services, events, and dependency injection—to give you total control over how views are counted and acted upon.