Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

This module tracks file downloads within IMCE, showing download counts as badges and providing detailed statistics in a modal. It supports private files and tracks who downloaded each file, how many times, and when.

Overview

The IMCE Download Tracker module provides comprehensive file download tracking and analytics within the IMCE file manager. It displays download count badges next to file names and offers detailed statistics through an intuitive modal interface.


Key Features

  • Download Tracking: Automatically tracks file downloads using Drupal's hook_file_download() (private files only)
  • Visual Badges: Shows download counts as blue badges next to file names with "Downloads: X" format
  • Real-time Updates: Download badges refresh automatically when navigating folders
  • Detailed Statistics: Tracks first download, last download, and download count for each file
  • User Tracking: Records which user downloaded each file
  • Modal Statistics View: View detailed download statistics in a responsive modal window
  • Permission Control: Configurable permissions for accessing download statistics
  • Clean Architecture: Well-organized, maintainable code structure
  • Drush Commands: Built-in Drush commands for managing and troubleshooting download statistics

Important Limitations

File Download Tracking:

  • Private Files: Download tracking works for files stored in private file system (private://)
  • Public Files: Download tracking does NOT work for files stored in public file system (public://) due to web server serving them directly
  • Workaround: To track public file downloads, consider using JavaScript click tracking or URL rewriting

Installation

  1. Install the module via Composer: composer require drupal/imce_download_tracker
  2. Enable the module: drush en imce_download_tracker -y
  3. Configure IMCE permissions: Go to Admin > Configuration > Media > IMCE and add the "Access download statistics" permission to your IMCE profiles

Usage

For Users

  • View Download Badges: Download count badges appear next to file names in IMCE showing "Downloads: X"
  • Automatic Updates: Badges update automatically when you navigate between folders
  • View Detailed Statistics: Select one or more files in IMCE and click the "Download Statistics" button in the toolbar

For Administrators

  • Configure Permissions: Go to Admin > Configuration > Media > IMCE and configure the "Access download statistics" permission
  • Database Schema: The module creates a file_download_stats table with download tracking data
  • Drush Management: Use built-in Drush commands for managing download statistics

Drush Commands

This module provides several Drush commands for managing and troubleshooting download statistics:

  • Recount Statistics: drush imce-download-tracker:recount - Recalculate download statistics for all files
  • Reset File Count: drush imce-download-tracker:reset [fid] - Reset the download count for a specific file by its file ID
  • View Statistics: drush imce-download-tracker:stats [--all] [--top=N] - Display download statistics for files

Examples:

  • drush imce-download-tracker:stats --top=10 - Show top 10 most downloaded files
  • drush imce-download-tracker:reset 123 - Reset download count for file ID 123
  • drush list | grep imce-download-tracker - List all available commands

Technical Details

Database Schema

The module creates a file_download_stats table with the following fields:

  • id: Primary key
  • fid: File ID from file_managed table
  • filename: The filename
  • uri: The file URI
  • download_count: Number of times downloaded
  • first_download: Timestamp of first download
  • last_download: Timestamp of last download
  • downloaded_by: User ID who last downloaded the file

JavaScript Architecture

The module is organized into logical sections:

  • INITIALIZATION: Setup and initialization functions
  • UTILITY FUNCTIONS: Helper functions and utilities
  • EVENT HANDLERS: Event management
  • STATISTICS DISPLAY: Modal and statistics display
  • BADGE MANAGEMENT: Badge creation and management

Requirements

  • Drupal 9, 10, or 11
  • IMCE module
  • File module
  • User module

Support

For issues and feature requests, please create an issue in the project repository. The module includes comprehensive logging for troubleshooting download tracking issues.

Contributing

Contributions are welcome! Please follow Drupal coding standards and create proper patches or pull requests.

Activity

Total releases
2
First release
Jul 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 2
Maintenance
Dormant

Releases

Version Type Release date
1.0.1 Stable Jul 15, 2025
1.0.0 Stable Jul 11, 2025