How to Track Downloads with Google Analytics

How to Track Downloads with Google Analytics

As we know, tracking engagement with any content you post online is key to understanding what your audience responds positively to, which aids your ability to continue to provide high-value content to your consumers. The same way we track page-clicks, if you offer downloadable content on your website, you’ll surely want to track how often it’s being downloaded. 

The great news: GA4 has automatic tracking of files with the following extensions: pdfs, xlsx, doc, txt, rtf, csv, exe, key, mp3, & more!

The not-so-great news: In a standard Google Analytics setup, there’s no built in tracking of these extensions.

But, there’s hope! If you haven’t yet made the jump to GA4, it is still possible to track inside Google Analytics (affectionately known here as GA), just with a bit of work. Follow the steps below to set up download tracking through Google Analytics. 

Why can’t Google Analytics automatically track downloads? 

Google Analytics tracks website activity on your pages through Javascript. Your website’s landing pages are filled with Javascript, and because Google Analytics’ base code is in Javascript, it can easily track website content. 

Downloadable files like PDFs don’t trigger JavaScript, so Google Analytics doesn’t know to record when these files are downloaded. This is true of any action a visitor on your site might make that doesn’t use browser-based code. 

In order to track website activity that doesn’t use Javascript, we have to manually tell Google what to track and how to track it. 

How to track downloads in Google Analytics 

There are a few methods you can use to track downloads. We’ll walk you through the step-by-step for both below. 

Method 1: Adding click-tracking code to a file download button


Most likely if your website features downloadable content, it does so via a clickable button that is coded to either kickstart the download or open a version of the download in a new window or tab. 

If you only have one or a few downloads on your site that you want to track, the easiest way to do so is to track the clicks of the button that triggers a download by adding a tracking code into the html of your site. 

By doing this, you’ll be able to tell Google Analytics to record a piece of user behavior that doesn’t trigger the Javascript tracking code it typically tracks. 

In order to set this up, all you’ll need to do is add some script to the code of the download button. If you’ve never had to work with html code before, don’t worry, we’ve got you covered. Below are step-by-step instructions and the exact code you’ll need to look for and add so all you need to do is copy and paste. 

Step 1: Within the html, locate the button on your site that prompts users to download content. Depending on what the text on your button says, this code will look something along the lines of: 

 <a href=”/my-file.pdf” target=”_blank”>Download this PDF</a>

In this case, “Download this PDF” is the text that appears on the button, so if you’re having trouble finding this within the code, try searching for the text on your download button. 

Step 2: To track clicks of this button in Google Analytics, you will add the following code: 


This will go directly between:

<a href=”/my-file.pdf” target=”_blank”


>Download this PDF</a>

Step 3:

Save the html and refresh your page to make sure it still looks the same (read: nothing went horribly wrong in the coding process). 

And there you have it! We’ve now written into the code of our button that when clicked, Google Analytics tracks and records it. Now you’re ready to log into your Google Analytics account and view the results of our download button tracking. 

The code you input on your website to track downloads enables download tracking as page views, so to get the downloads report, you’ll navigate to: 

Behavior >> Site Content >> All Pages

And voila! 

Method 2: Google Tag Manager

If you want to track all downloads on your website, rather than manually adding code to each of the file links on your site, you can add tracking automation using Google Tag Manager. 

With Google Tag Manager, you can add tags to your website that can be associated with just about any element. If you have GTM on your site already, all you need to do to track your downloads is create an event trigger. The trigger will record an event in Google Analytics any time a visitor clicks on your download link. 

If you don’t have GTM set up on your site yet, here is a Google Support article that will walk you through how to download Google Tag Manager and get started. We’ll see you back here once it’s installed and you’re ready to go! 

Here’s the step-by-step of how to tell Google Tag Manager to track when someone clicks a link on your website: 

  1. In your Container Overview menu on Google Tag Manager, click New Tag, specify it’s a Universal Analytics (UA) tag, and name the tag “Link Click Listener"
  2. This will prompt you to Choose a Trigger. Click the + in the top right corner. 
  3. Click the Trigger Configuration box, then within the Click category, select Just Links
  4. Under “This Trigger Fires On,” select “Some Click Links”
  5. Now you should be able to select the conditions under which you want the trigger to fire. In the first box, select the URL that prompts the download on your site.
  6. In the second box, select “matches RegEx” 
  7. In the third box, put the extension name of whatever file type you’d like to track. 
  8. For example, if you’re tracking PDF downloads, your third box should say, “.pdf” or If you’re tracking JPG downloads, it should say “.jpg”
  9. Once you’ve created your trigger, hit “Save” and you’re done! 

Now if someone clicks a link on your site that contains .pdf, .jpg, .xlxs, or whatever it is that you’re tracking, this trigger will fire, and that action will now record a download event in Google Analytics.

Here’s an example of what data will look like in Google Analytics tracking .png file downloads using Google Tag Manager: 

example of download tracking within Google Analytics

These two ways are the industry standard for tracking downloads in Google Analytics. Now you’re able to track this important form of engagement on your website and better understand users’ journeys on your site. 

We’re here to help. 

Still confused? We’re here for you! We help a variety of clients, from zoos and museums, to universities and health systems, track what’s important to them. To discuss your needs, reach out to our Business Development team. We’d love to hear from you!

Get In Touch  

Posted by Kindra Svendsen at 07:10