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.
- Tracking downloads using events
- Automated download tracking
- Google Tag Manager downloads tracking
- WordPress plugin for downloads tracking
Why doesn’t Google Analytics automatically track 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.
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:
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.
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…
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.
You can configure your trigger using the event tracking templates in GTM.
Within the trigger, you can use a regular expression to fire an event based on your file extensions.
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.
Here’s an example of data in Google Analytics from tracking .png file downloads using GTM.
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.
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.
But what if you can’t use GTM or MonsterInsights?
Analytics Course Student question:
One of my Analytics Course students, Marco, was faced with this problem.
My client wishes to track PDF download. I remember you talking about that. The best way is to use Google Tag Manager. Alas, I am stuck with Google Analytics. So I need to set up Event Tracking I believe.
Is this the proper code to insert in the GA script? And where exactly would developers place it?
Marco can’t use GTM for his client’s website. So, he want’s to know how to track PDF downloads using the Google Analytics code.
Let’s look at the options for tracking PDF downloads without GTM or a plugin.
1. You can manually add code to each PDF you want to track
Manually adding code sounds complicated, but there is a tool that can help you create event tracking links.
Raven Tools has a form that allows you to build event tracking code for your download links.
Their form will create two sets of tracking code. You can choose to use either line of code in your download URL.
The second line of code offers a more comprehensive link, embedded in a link tag.
You can copy either of these lines of code and embed them in the link for your downloadable file. This code will trigger a download event in Google Analytics anytime someone clicks your file link.
2. Use Google Analytics Autotrack
Google introduced Autotrack to help users that can’t make frequent website updates.
You can use Autotrack to track outbound link clicks on your website automatically.
Autotrack will allow you to declare the link click event you want to track.
So if your PDF or other download is accessible via a button, you can track it using Autotrack.
In the event tracking code, you adjust the data-event-category to register based on your button click. And you make the data-event-action equal your download.
For this to work, you need to have Autotrack installed. You also need to have control over the metadata in your website’s HTML.
These tracking options might be starting to sound pretty advanced, but not every analytics solution is easy. That’s why we started with the simpler solutions first.
In general, the more difficult solutions provide more control. But they take more time to implement.
With that in mind, let’s talk about how you custom code your site to track downloads in Google Analytics.
3. Write code to find any link ending in .pdf, and automatically append event script
Custom coding is the most advanced solution. It involves writing your own code. Then you have run tests using your own systems to make sure your code executes correctly.
Here’s an example of what your code would need to communicate with Google Analytics to track your downloads. (This is not the actual code for this operation. This example is written using a computer science technique known as pseudocode.)
If the other options we covered so far don’t work, you can try to find a third party tool to help you track your downloads.
I know these libraries exist, or they did at one time. But, my searches to find a library to share did not produce any results. It’s possible these tools were made extinct by GTM.
So, I don’t have an example of a third-party tool that does automatic event tracking. But I’m pretty sure there’s one out there somewhere. If you can recommend a third-party tool for event tracking, please leave a comment below. We’ll update this section of the post with your suggestions.
The bottom line is…
You have a lot of options to track downloads in Google Analytics.
The best solution, in my opinion, is GTM. But the strategy you choose depends on your website setup and the resources at your disposal.
Which technique do you use to track downloads in Google Analytics?
Let us know, which one of these tacking techniques works best for you? Leave a comment below with method you use for track downloads. Also, if you use a strategy we didn’t cover, share it in the comments. We’ll continue to expand this post with your recommendations.