How do I count downloads of a PDF or zip file on my site?

Count the click on the download link with a named event goal, or send people to a download page and count that page with a page goal. PostDeploy cannot see the file itself, because a PDF or zip opened straight from a search result or a shared link never runs the script. Expect server logs to show more.

Last updated 26 November 2026. By Paul Badarau.

A fictional architecture studio has a portfolio PDF and a press kit zip on its About page. It adds two named event goals, download_portfolio and download_press_kit, and a month later the report shows 58 and 9. The file host's log shows 140 requests for the PDF in the same month. Most of the difference is a search result and a forum post that link straight to the file, so those readers never saw a page with the script on it.

There are two ways to count a download:

  • Count the link click. Add a named event goal and send it when a visitor clicks a link to the file. Use this when the file sits next to other content, as on the studio's About page.
  • Count a download page. Link to a page such as /press-kit that holds the file link, and add a page goal for that path. It needs no code, and it counts people who reached the page rather than people who clicked the file.

For the link click:

  1. Ask an Owner or Administrator to add a named event goal for each file you want to tell apart, plus file_download for every other file. An event carries the goal name and the page it happened on, not the file name, so files you want counted separately need goals of their own.
  2. Tag those links: <a href="/files/portfolio.pdf" data-goal="download_portfolio">Portfolio (PDF)</a>.
  3. Add one script for the whole site: function download(event) { var link = event.target.closest('a[href]'); if (link && /\.(pdf|zip)$/i.test(link.pathname)) window.postdeploy?.track(link.dataset.goal || 'file_download'); } document.addEventListener('click', download); document.addEventListener('auxclick', download);
  4. Download each file once yourself and check that its goal appears.

The PostDeploy script hands the event to the browser's beacon where it can, which is built to deliver requests while a page unloads.

The count will be lower than the true number of downloads. The script runs only on your pages, and a PDF or zip opened directly runs nothing, so links from search results, email and other sites that point straight at the file go uncounted. Save link as from the right-click menu fires no click either. And a click is not proof the file finished downloading. If you need every request, read the server or file host log, and keep that number apart from your goals. A Project holds at most 40 goals, archived ones included, so give separate goals only to the files you would act on.

The product page for this is Analytics.

Start your 14-day free trial