Drupal is a registered trademark of Dries Buytaert

imce_download_tracker

8 sites No security coverage
View on drupal.org

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
7 months ago
Release cadence
4 days
Stability
100% stable

Releases

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