Tracking file downloads from a website

By

Learn how to track file downloads on a static website with Plausible, swapping in its file downloads script and listing extensions like pdf and epub.

~~~

I had the need to track file downloads on a website.

I initially looked into using URL shorteners that provided stats, as I assumed that was my only option without a backend (was building a static site) but nothing really excited me.

Then I saw Plausible can track file downloads.

The setup is simpler now. Open the site’s Plausible settings, go to General → Site Installation, and enable File downloads as an optional measurement. You do not need to swap the tracking script by hand.

Plausible tracks common extensions such as PDF, ZIP, DOCX, MP3, and MP4 by default. A click is recorded as a File Download event, and the file URL is available as an event property.

There are two limitations worth knowing:

If you install Plausible through its JavaScript API, you can enable the feature in code and override the default extension list:

plausible.init({
  fileDownloads: {
    fileExtensions: ['pdf', 'epub']
  }
})

Setting fileExtensions replaces the default list, so include every extension you want to track.

~~~

Related posts about tutorial: