Download Tracker —a new Drupal module to track file downloads

I wanted to track downloads of my applications, and no existing Drupal modules seemed to do exactly what I want to do, so I asked Antigravity to create one. I called it Download Tracker.

It has fine grained directory access, and can track public and private files served by Drupal.

It also keeps track of new vs old users using a cookie, and tracks different versions of the files:

This module was created by Antigravity, and here is its .md file:

Download Tracker

Drupal Core CompatibilityPHP VersionLicense

Download Tracker is a high-performance Drupal module that monitors administrator-configured server directories for file changes and software releases, tracks file reads and downloads, and automatically categorizes downloads into New Users, Version Updates, and Repeat Downloads.


🌟 Key Capabilities

Mermaid diagram
  • 📂 Watched Directory Management: Monitor any server folder (e.g., /sites/default/files/release, public://release, private://documents).
  • 👥 Role-Based Download Control: Granular access permissions per directory (e.g. restrict to Authenticated users or leave open for Anonymous visitors).
  • 🔐 Report Permissions in UI: Conveniently configure which roles can view analytics directly from the module settings page.
  • ⚡ Intelligent Version Auditing: Automatically computes SHA-256 integrity hashes on disk to detect file updates and increment release versions (v1

    v2

    v3...).
  • 📊 Visual Analytics Dashboard:
    • High-level summary metrics cards (Total Files, Total Hits, New vs. Update vs. Repeat).
    • Interactive data table with multi-column sorting across all metrics.
    • Drill-down per-file audit trail with SHA-256 version history and chronological access logs (IP, User ID, Referrer, User-Agent).
    • One-click CSV Export.
  • 🛡️ Transparent Static Link Redirection: Direct links to static file paths (e.g. https://example.com/sites/default/files/release/app.exe) automatically redirect to the tracker endpoint so no download is missed.
  • 🤖 Bot & Crawler Filtering: Automatically filters out search engine spiders (Google, Bing, Yandex, etc.) to keep your metrics clean.

🚀 Quick Start Guide

1. Installation

bash
composer require drupal/download_tracker

Enable Module via Drush

bash
drush pm:install download_tracker

(Alternatively, enable via the Drupal administration interface at Extend (/admin/modules).)

2. Configuration

Navigate to Configuration

Media

Download Tracker (/admin/config/media/download-tracker):

  1. Report Access Permissions: Check the roles permitted to view reports and statistics.
  2. Watched Directories: Configure your folders:
    • Machine Key: e.g., release
    • Label: e.g., Software Releases
    • Directory Path: e.g., /sites/default/files/release or public://release
    • Allowed Roles: Select roles allowed to download, or leave unchecked for open public access.
  3. Click Save and Scan Directories Now.

TIP

Both standard paths with leading slashes (/sites/default/files/...), relative paths (sites/default/files/...), and Drupal stream wrappers (public://..., private://...) are automatically supported.


🔗 Clean Download URLs

You can share clean, tracked download links anywhere on your site, in documentation, or in emails:


https://example.com/download/{directory_key}/{filename}

Example:

https://example.com/download/release/WhatBeeped_Setup_v1.0.exe

NOTE

Automatic Static URL Interception: If users or external sites access legacy direct links like https://example.com/sites/default/files/release/WhatBeeped_Setup_v1.0.exe, the module automatically intercepts the request, routes it through the tracker to count the hit, and streams the file immediately.


📈 Reports & Analytics

Access your analytics at Reports

Download Tracker (/admin/reports/download-tracker):

Metric Badge Description
New Users New User First time this visitor has ever downloaded this specific file.
Version Updates Version Update Visitor previously had an older version (e.g. v1), and is now downloading the updated release (v2).
Repeat Downloads Repeat Visitor is re-downloading the same version they already downloaded previously.
  • Interactive Sorting: Click on any table header (Directory, Filename, Version, Size, Last Modified, Total Downloads, New Users, Updates, Repeats) to sort ascending or descending.
  • Drill-Down Audit: Click Details & History on any file to inspect its full SHA-256 version timeline and timestamped access logs.
  • Export Data: Click the Export CSV action button for reporting and offline analysis.

⚙️ Drush CLI Integration

Command Alias Description
drush download-tracker:scan drush dt-scan Manually triggers a scan across all watched directories to catalog new files or version bumps.

📋 Requirements & Compatibility

  • Drupal Core: ^10 || ^11 || ^12
  • PHP: ^8.1 || ^8.2 || ^8.3
  • Database: MySQL / MariaDB / PostgreSQL / SQLite

📄 License

This project is licensed under the GNU General Public License, version 2 or later (GPL-2.0-or-later).

 
 
2:11 PM
 

 

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Comment

  • Allowed HTML tags: <b> <h2>
  • No HTML tags allowed.

The comment language code.

CAPTCHA

Enter the characters shown in the image.

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.