PDF Tracking in Google Analytics through GTM

How To Track Downloads In Google Analytics – Complete Guide

Do you have a whitepaper, ebook, PDF, or other files offered as downloads on your website?

If you do, you probably want to track how often your visitors download this content.

Tracking downloads on your website can help you figure what motivates your visitors. It can also help you determine which kind of content upgrades your audience really wants.

Google Analytics does not automatically track this activity. But…

You can set Google Analytics up to track downloads automatically.

Depending on your website’s setup and your resources, there are a number of options for tracking file downloads.

Let’s look at how this tracking works in Google Analytics. Then we’ll walk through the options you have available for tracking downloads. We’ll start with the easiest solutions, and end with the most difficult.

Google Analytics loves to track pageviews. Why? Because web pages execute JavaScript when they load in your browser. The base Google Analytics code is built in JavaScript, so it can track anything that executes JavaScript.

But what about web-based activity that doesn’t execute JavaScript?

PDFs and other types of downloadable files don’t trigger JavaScript. So the standard Google Analytics tracking code does not record file downloads.

The same applies to user activity on a web page. If the user’s action doesn’t trigger your code, Google Analytics won’t track it.

If you want to track events that don’t execute browser-based code, you have to do some extra work. You have to tell Google Analytics what you want to track, and how to track it.

Using event tracking and virtual page views to track downloads

There are two ways you can tell Google to track downloads on your website.

You can use event tracking, or you can create what’s known as a virtual pageview.

Event Tracking

There are a couple different ways to set up event tracking.

You can put some additional code on your website. Or you can use a plugin that puts the event tracking code in place for you.

Event tracking is critical to understand because it’s a fundamental part of Google analytics.

Event tracking is how you tell Google Analytics to record user behavior that doesn’t automatically trigger your tracking code. Usually, events are actions on the pages of your website. Common examples of events include video views, page scrolling, or file downloads.

Event code looks like this:

Google Tag Manager event code example

The event code sends a hit to Google with the category of the event. It also tells Google the action that occurred and gives that action a label. In the event code, you can also tell Google to assign a value to the event.

Interaction Events

An interaction event is a true or false type of command that exists within the event code. It tells Google that something did, or did not happen based on the user interacting with your webpage.

Interaction events can be used to track bounce rate more precisely. Non-interaction events don’t affect your bounce rate at all.

Automated download tracking

Adding event tracking code to one file isn’t overly complicated.

But if you don’t want to add code to your files manually, there are automated alternatives. Automation is also a better solution if you need to track many downloadable files.

There are several automated solutions for tracking downloads on your website.

Tracking downloads using Google Tag Manager

My favorite solution for tracking file downloads, hands down, is…

Google Tag Manager (GTM).

Google Tag Manager home page

I love using GTM to track downloads because it’s easy to set up.

If you have GTM on your website, all you need to do to track your downloads is create an event trigger.  The trigger will record an event in Google Analytics every time a visitor clicks your download link.

Google analytics options within google tag manager

You can configure your trigger using the event tracking templates in GTM.

setting up a link click event to be sent to google analytics

Within the trigger, you can use a regular expression to fire an event based on your file extensions.

using a regular expression between google analytics and google tag manager

This expression tells the trigger to fire if any of these extensions are present in your URLs. So, if someone clicks a link on your site that contains .pdf or .xlxs, etc. this trigger will fire. And that action will record a download event in Google analytics.

zoomed in on expression used

Here’s an example of data in Google Analytics from tracking .png file downloads using GTM.

example of download tracking within Google Analytics

Tracking downloads using GTM is a very straightforward process. And it’s the industry standard for measuring this type of event.

But, if for some reason you can’t use GTM, there are other options.

My second favorite way to track downloads is using a WordPress plugin.


I used MonsterInsights for years before GTM came along.

monster insights

The MonsterInsights interface allows you to track file downloads automatically. And they give you the option to use events or virtual page views.

This plugin also allows you to choose the type of file extension you want to track.

Tracking your downloads in MonsterInsights extremely easy to configure, and it’s a comparable option to GTM.