Track File Downloads Without Guesswork
Why downloads need their own tracking
Pageview analytics often miss file downloads. A click on /files/ebook.pdf may not create a pageview. It creates a file request. If you only look at pageviews, you may think nobody wants your lead magnet when they actually downloaded it. Separate download tracking answers questions like which asset gets clicked, from which page, from which campaign, and whether it leads to a signup.
Decide what counts as a download
Before adding tracking, define what you mean by a download. Common definitions include:
- A click on a link or button pointing to a file.
- A completed file request in server logs.
- A download event after the browser starts receiving the file.
Click tracking is usually the simplest because it happens in the browser and can include page, source and campaign context. Server logs count requests but may include bots, search crawlers and failed requests. Choose one definition and use it consistently so your numbers stay comparable over time.
Track download clicks with a data attribute
The fastest method is to add an event attribute to each download link or button. When someone clicks it, the analytics tool records a custom event. You can then view download events alongside pageviews.
For a button, the attribute may look like this:
<button data-measuremysite-event="download_ebook">Download the ebook</button>
For links, check your analytics tool's documentation for the exact attribute. Many tools accept the same attribute on anchors. If yours only supports buttons, you can use a button styled as a link or keep the link and attach a click handler.
Name events consistently. Use download_ebook, download_pricing_sheet and download_setup_zip rather than download1 and download2. Consistent names let you compare downloads across pages and campaigns without cleaning data later.
Track downloads from server logs
If your files are on your own server, you can count requests to .pdf, .zip, .csv and other file paths. This catches downloads that start without a click, such as direct links from emails or bookmarks. However, logs are noisy. Bots, link previews, download managers and retries can inflate numbers. Filter by user agent, request method and status code if you can. This is more work than click tracking but useful as a sanity check.
Add UTM parameters to download links in emails and social posts
When you share a download link in a newsletter or social post, add UTM parameters. The download event itself may not carry the campaign, but the page the visitor lands on will. If someone clicks a link from your newsletter to a landing page and then downloads the file, the landing page source is attributed to the newsletter. This gives you campaign-level download data without changing the file itself.
Example campaign link:
https://example.com/ebook?utm_source=newsletter&utm_medium=email&utm_campaign=may_launch
The download click on that page can then be viewed by the same source, medium and campaign if your analytics tool attaches campaign data to events.
Build a funnel from download to signup
A download is rarely the final goal. You want to know how many downloaders become customers or subscribers. Build a funnel with these steps:
- Visit to the landing page.
- Click on the download link or button.
- Visit the signup or pricing page.
- Click signup.
If you use measuremy.site, you can build this from page paths and custom events. The download click is an event, and the signup click is another event. The funnel shows where people drop off between reading about the file and completing the next step.
Avoid double counting and false downloads
Download tracking can overcount if you are not careful. Watch for these issues:
- A click event and a server log entry for the same download. Pick one as your primary metric and use the other as a check.
- Prefetching or prerendering by browsers may fire events without a visible click. Check your analytics tool's settings if downloads look inflated.
- The HTML
downloadattribute can change browser behaviour, but it does not create a tracking event by itself. - Links to the same file in the footer, sidebar and body will all fire events. Use distinct event names if you need to know which placement works.
- Bots clicking links can create fake download events. If your tool does not filter bots, compare event counts with real signups over time.
A practical setup in five steps
- List the files that matter: lead magnets, product sheets, sample data, installers.
- Give each one a clear event name, such as
download_pricing_sheet. - Add the event attribute to the link or button on every page where it appears.
- Add UTM parameters to external links that point to the download landing page.
- Build one funnel from download to signup and check it weekly.
Tracking file downloads gives you a clearer picture of what your visitors actually want. Start with click events because they are quick to set up and easy to read, then add server log checks if you need to catch direct requests. Name events consistently, avoid counting the same download twice, and connect downloads to the next step in your funnel so you know whether the file is doing its job.
See it on your own site
measuremy.site is cookieless analytics your coding agent can read. 30-day free trial, no card. Plans from $9/month.
Start free trial See the live demoAdd measuremy.site analytics to this project: connect the measuremy.site MCP server at https://a.measuremy.site/mcp for all my projects (claude mcp add --scope user; it signs in with OAuth, no key, and one sign-in covers every site), then tell me how to sign in. Details: measuremy.site/llms.txt
Free tools
- Analytics tag checker: Which analytics and pixels a site runs, plus duplicate and broken tags.
- Free UTM link builder: Add utm_source, medium and campaign to any link.
- Website traffic checker: A site's popularity rank and estimated monthly visits.
More from the blog
- How to calculate your website conversion rate, and what to compare it to
- Is my A/B test result significant? A plain-English guide with a worked example
- What is bounce rate, how is it calculated, and is yours a problem?
- How to add a visitor counter to your website or GitHub README
- How much traffic does a website get? How to estimate any site's visits
- How to track QR code scans: count them, and see which poster worked
- How to see how many people clicked your link (without a paid shortener)
- How to check if your Google Analytics 4 tag is installed (and only counting once)
- Why GA4 shows your campaign traffic as Unassigned (and how to fix the links)
- Does your redirect keep your UTM tags? How to check before a campaign goes out
- How I built a self-hosted analytics MCP server on Cloudflare Workers and D1
- UTM tracking explained: what the parameters mean and how to use them
- Conversion funnel analysis for small sites: a practical guide
- Sudden drop in website traffic? A checklist for finding the cause
- What is an MCP server? A plain-English guide for people who run websites
- Adding analytics to a Next.js app without slowing it down
- Core Web Vitals and Traffic: Is There a Link?
- Analytics After Cookies: What Actually Changes
- GDPR and website analytics: a practical guide for small sites
- How to Compare Website Analytics Tools by Privacy
- GA4 Events Explained for Beginners
- How to measure a newsletter send with UTM links
- How to track Hacker News traffic
- Adding Analytics to a Framer Site
- How to ask your coding agent about your analytics
- What Is Bounce Rate and How Is It Calculated?
- A practical website analytics retention policy
- Map your site's funnel from first visit to signup
- What Is a Good Bounce Rate?
- How to automate a weekly traffic report
- A Practical Privacy-Friendly Analytics Checklist
- Adding an MCP server to Claude Code
- How long should you keep analytics data?
- How to Build a Small MCP Server That Actually Helps
- How to Find the Biggest Drop Off in a Funnel
- What Is the Urchin Tracking Module?
- What Microsoft MCP servers actually do
- UTM parameters for email newsletters
- Track Button Clicks Without Google Tag Manager
- How to track the results of a social media post without cookies
- How to track traffic from a GitHub README
- How to measure a product launch without guessing