Download the PHP package coysh-digital/craft-download-tracker without Composer

On this page you can find all versions of the php package coysh-digital/craft-download-tracker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package craft-download-tracker

Download Tracker for Craft CMS

Count how many times each of your files gets downloaded - without bloating your database.

A lot of the download-tracking tools I found wrote a new database row (or even a whole element) for every single download. On a busy site that table balloons into millions of rows and starts to hurt, I found that sites that had static caching enabled were refreshing the cache constantly. Download Tracker takes the opposite approach: it keeps one running counter per file and increments it atomically. A file downloaded a million times is still a single row.

It's also built for modern, cache-first Craft sites. If you run full-page static caching such as Blitz, you'll know that a cached page never touches PHP - so anything that tries to "count on page load" simply never fires. Download Tracker sidesteps this entirely by counting on a lightweight background request that static caches always let through.

Features

Screenshots

The Downloads screen — every tracked file, its running total, the crawler share, and when it was last pulled, searchable and sortable, with CSV export:

Each file has a detail screen with its people-vs-crawler totals and a day-by-day chart over the last 30, 90 or 365 days:

Documentation

Full documentation lives at coysh.digital/plugins/download-tracker/docs. This README is the short version; the docs go deeper on installation, click tracking, managed links, crawlers, the Twig API, reporting, settings and the Link Vault import.

Requirements

One release covers both: there's no separate Craft 4 branch or version line to pick between. It's handy if you want to import your Link Vault history and drop Link Vault before upgrading to Craft 5, rather than carrying it through the upgrade.

Installation

Install with Composer and then enable the plugin:

Or install it from the Plugin Store in your control panel.

How it works

Downloads are counted through one of two routes, and both update the same counter - so a file is never double-counted.

1. Automatic click tracking (the default)

With Auto-track download links switched on, the plugin adds a tiny script to your front-end pages. When a visitor clicks something that looks like a download

You don't have to change any of your templates or links. To exclude a specific link, add data-dt-ignore to it.

2. Managed download links (optional)

When you want a download counted reliably on the server - for example a members-only PDF, a file on private/off-server storage, or a link that should force a “Save as…” - route it through the plugin:

The link carries a signed token, counts the download when clicked, and then either redirects to the file (for public assets) or streams it through Craft (for private or off-server assets).

Crawlers

Search engines, AI crawlers, link unfurlers and uptime monitors all download files, and left alone they quietly inflate your numbers. Crawler downloads in the settings decides what happens to them:

Browser prefetch and prerender requests are always served and never counted, whichever you choose - a prefetch is a real browser getting ready for a real click, so it's neither a crawler to turn away nor a download to count.

The plugin knows the well-known crawlers by name and catches most of the rest by their User-Agent; Extra crawler user agents takes anything else you spot in your own logs. It deliberately doesn't record which crawler made a download: that would mean a row per file per crawler per day, which is exactly the row growth this plugin exists to avoid.

A note on private files: a download link is a bearer link - anyone who has the URL can use it. If you place a managed link to a private asset on a publicly cached page, that URL gets baked into the cached HTML and becomes a permanent public link. For genuinely private files, turn on Require login, and/or set a Signed URL lifetime and only render the link on pages that aren't statically cached (such as logged-in account pages).

Reading the numbers in Twig

All of these accept an Asset, an asset ID, or a URL/path string — except url(), which takes an Asset.

daily() returns one entry per day, oldest first, with days that saw no downloads included as zeroes, so you can chart it without minding the gaps:

Tip: avoid printing a live download count directly into a statically cached page - the number would freeze until the cache is regenerated. Show counts in the control panel, or load them with a small client-side request.

Settings

Everything is configurable in Settings → Download Tracker, or in a config/download-tracker.php file (which takes precedence, and is handy for per-environment values):

Setting What it does
Auto-track download links Injects the click-tracking script on the front end.
Tracked path prefixes URL paths whose links should be counted, e.g. /assets/files/.
Tracked extensions File types to treat as downloads (pdf, zip, csv, …).
Track download-attribute links Also count any link with a download attribute.
Excluded hosts Hostnames to ignore, e.g. an image CDN.
Track non-asset files Also count links that don't resolve to a Craft asset. Off by default.
Crawler downloads Count crawlers separately, don't count them, or block them with a 403.
Extra crawler user agents Extra User-Agent tokens to treat as crawlers, on top of the built-in list.
Serve mode How managed links deliver files: redirect, stream, or auto.
Force download Serve managed downloads as an attachment (“Save as…”).
Require login Only serve managed downloads to logged-in users.
Signed URL lifetime How long a managed download link stays valid (0 = forever).
Daily rollup retention How many days of per-day history to keep.

Moving from Link Vault

If you're coming from Link Vault, your download history can come with you. Link Vault keeps a row per download; this plugin keeps a count per file, and the importer folds one into the other.

Do this before you uninstall Link Vault. The importer reads Link Vault's tables directly, so the history is gone once they are. Link Vault isn't modified or removed - you can import, check the numbers, and only then uninstall it.

Still on Craft 4? This plugin runs there too, and Link Vault's tables are identical on both, so you can import your history and drop Link Vault before upgrading to Craft 5, rather than carrying it through the upgrade.

With both plugins installed, go to Download Tracker → Import (admins only; the page only exists while Link Vault does). It shows what it will do before you commit to anything, then runs in the background - progress appears in the control panel's queue indicator. For a very large history you may prefer the console:

It's safe to run more than once: it resumes rather than counting anything twice. So you can import, leave Link Vault running a little longer, and run it again to pick up the stragglers before uninstalling.

Kept: each file's running total, its last-downloaded date, and its day-by-day history (as far back as your Daily rollup retention allows - set it to 0 before importing to keep the lot). Not kept: who downloaded what and from which IP, custom fields, and the people/crawler split, since Link Vault never recorded a user agent. See the Link Vault import docs for the full detail.

Support

Found a bug or have a request? Please open an issue on GitHub.

License

This plugin is commercial software, released under a commercial license. See LICENSE.md for details.

Made by Coysh Digital.


All versions of craft-download-tracker with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
craftcms/cms Version ^4.0.0|^5.0.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package coysh-digital/craft-download-tracker contains the following files

Loading the files please wait ...