Download tracking
Which files people download, recorded from the link click with no code: the extensions recognised, the download attribute and how to exclude a link.
A click on a link to a file is a download event with the URL, the file name and its extension. Top files are under Goals › Captured automatically, and name is download filters any report to the visits that downloaded something.
What counts as a download
A link whose path ends in one of these extensions:
Documents pdf doc docx xls xlsx ppt pptx csv txt epub ics json xml sql
Archives zip rar 7z tar gz tgz iso
Installers exe msi dmg pkg apk deb rpm
Media mp3 wav mp4 mov avi mkv
Design psd ai sketch fig svg ttf woff woff2Or any link with a download attribute, whatever the URL looks like. Then the attribute's value is the file name, which is how a link such as /export?report=42 is reported as q3-report.csv.
<a href="/export?report=42" download="q3-report.csv">Download report</a>Properties
| Property | Example |
|---|---|
| url | https://yoursite.com/files/Q3%20report.xlsx |
| file | Q3 report.xlsx |
| ext | xlsx |
Excluding a link, or all of them
<a href="/terms.pdf" data-statsy-ignore>Terms</a>
<script defer data-website-id="ws_XXXXXXXX" data-track-downloads="false" src="https://statsy.co/js/script.js"></script>How it is sent
The event leaves with sendBeacon in the click's capture phase, before the browser follows the link, so it is delivered even when the download navigates away. Files fetched by JavaScript and saved from a blob are not links, so record those with statsy.goal('download', …) where you trigger them.
Note. A download to another domain is also an
outboundclick. Both are recorded, and both count as an event, so a site whose files sit on a CDN domain uses two events per download. Setdata-domainto your CDN too, or switch off outbound tracking, if that matters.
Frequently asked questions
Can I see the file size or whether the download finished?
No. The browser tells a page nothing about a navigation download once it starts, so only the click is knowable.
Can a download be a goal with a value?
Yes. Create a goal named download on the Goals page and give it a default value, and each download counts that value.
Last updated · Markdown version