How to track PDF downloads in Google Analytics 4

Ben

Co-Founder

15 August, 2023 • Reading time: 8 minutes

How to track PDF downloads in Google Analytics 4

Set up Google Analytics 4 to properly track PDF downloads on your website.

We love using Google Analytics 4 to track how people are interacting with our website, but by default Google Analytics 4 will not track how many times people download PDFs or other file types.

This simply because those files do not have the ability to request a tracking pixel, which is the method Google Analytics 4 uses to track what people are doing on your website.

A few benefits of tracking PDF downloads are:

    • Discover how popular your downloadable PDFs are

    • Find out which content type you should offer more and which aren’t getting downloaded much

    • Save your time and money by only producing the PDF content your audience actually wants

In this article, we’ll look at several ways you can set up Google Analytics to properly track PDF downloads. Some of the methods are easier than others, so have a read through and check which method is best for you.

Method 1: Google’s Official GA4 Method

In Admin, under Data display, click Events.
Click Create event and then Create.

In the Custom event name field, enter the name “white_paper_download”.

In the Matching conditions section, enter the first matching condition “event_name” equals “file_download”, then click Add condition.

Enter the second matching condition “file_name” equals “My White Paper”.

Click Create.

To measure when someone completes a registration form as a conversion:

In Admin, under Data display, click Conversions.
Click New conversion event.

Enter the name of the new event, “white_paper_download”.

Click Save.

 

Method 2: Adding a script to the PDF download link

If you are linking to a PDF that opens in a new window (by using target=”_blank” for example), then the tracking code is fairly simple to implement.

Your link will look something like: <a href=”/my-file.pdf” target=”_blank”>Download the PDF</a>

To properly track this in Google Analytics, add the following code to link tag:

<a href=”/my-file.pdf” target=”_blank” onclick=”_gaq.push([‘_trackEvent’,’Download’,’PDF’,this.href]);”>Download the PDF</a>

When a user clicks to download your file, a tracking pixel is requested and recorded in your Google Analytics.

That solves the problem for individual PDF downloads, but what if you want to track any PDF download on your website?

 

Method 3: Using a WordPress plugin

Many of our clients have built their websites using WordPress, so luckily for them there are a range of WordPress plugins that allow you to track PDF downloads.

To enable PDF downloads tracking, we recommend using a WordPress plugin like MonsterInsights.

After installing and setting up the plugin, file downloads tracking will be enabled automatically and they will be tracked as events. But the good part is that you don’t have to do any further configuration, as MonsterInsights will take care of it.

By default, MonsterInsights lets you track downloads of the following file extensions: doc, pdf, ppt, zip, xls, docx, pptx, and xlsx. But you can add more extensions that you want to track.

In Google Analytics, events tracking are used to measure user interactions with content like downloads, mobile ad clicks, video plays, etc.

 

Method 4: Google Tag Manager

If your website isn’t built on WordPress and you want to track all PDF downloads, not just individual PDFs, you’ll need to use Google Tag Manager.

Google Tag Manager allows you to add tags to your website that can be associated with almost any element – buttons, time on a page, clicks.

The video below describes how to install Google Tag Manager, as well as an introduction to the software, but there are also written instructions for how to install Google Tag Manager here.

 

There are three main components of Google Tag Manager:

    • Rule – A name given to a condition or set of conditions

    • Tag – Triggers an event when a rule is met

    • Container – the “box” that holds all your rules and tags

Before you can measure PDF views, you need to first ensure that anytime someone clicks a link on your website, that click is tracked: a Link Click Listener tag accomplishes this.

    1. In your Container Overview menu click New » Tag and name the tag “link click listener”
    2. Under “Tag Type” select Event Listener » Link Click Listener
    3. On the right hand side of the screen, click “+Add” next to “Firing Rules” and select “All pages”
    4. Google Tag Manager creates the “All pages” rule automatically
    5. Save

This creates a tag that says, via code, “On all pages of this website, whenever someone clicks on a linked element, I will create an event called gtm.linkClick.”

Link Click Listener in Google Tag Manager

Now that you’re measuring all link clicks on your website, you need to hone in PDF clicks specifically, which means creating a new rule to identify PDF clicks.

    1. In your Container Overview menu click New » Rule and name the rule “PDF click”
    2. Under “Conditions” select {{event}} » equals » gtm.linkClick.
    3. Remember, gtm.linkClick is the item generated by your Link Click Listener tag
    4. Add another condition – {{element url}} » contains » .pdf
    5. Save

This creates a rule that is only met when someone clicks on a link with .pdf in the url string.

PDF Click in Google Tag ManagerPDF Click in Google Tag Manager

Next you’ll need to create a “PDF View” tag. This tag will add an event to your Google Analytics account anytime someone clicks on a PDF.

    1. In your Container Overview menu click New » Tag and name the tag “Analytics Event – PDF View”
    2. Select “Tag Type” Google Analytics » Universal Analytics
    3. Add your Google Analytics tracking ID to the “Tracking ID” box
    4. Under “Track Type” select Event
    5. In the “Event Tracking Parameters” assign the following names. These will help organise events within Google Analytics as you add more tags):
    6. Category – micro-conversion
    7. Action – {{element url}}
    8. Label – pdf-view
    9. Click “+Add” next to “Firing Rules” and select “pdf click”
    10. Save

Now you’ve installed the tag, you can test they’re working using the following step-by-step:

    1. In the upper-right corner of your Container Overview menu click Preview » Debug
    2. Visit your website in a new tab
    3. Click on a PDF on your website
    4. If the menu bar below reads “Tags Fired on this Page: Analytics Event – PDF View,” then you’re set.
    5. If not, go back and look for mistakes. A single typo or space can stop the tag from firing correctly.
    6. Exit debug mode.

PDF view tag firing in Google Tag ManagerPDF view tag firing in Google Tag Manager

Now the tag has been added and tested as working correctly, you can create a “PDF View” goal in Google Analytics:

    1. In your Google Analytics account, select “Admin” from the primary navigation.
    2. Select the property (whose tracking code you used in Google Tag Manager) and the view you want to create the goal in.
    3. Click Goal » New Goal, name the goal “PDF View” and select event under the “Type” menu. Click next.Under “Event Conditions” set category » equals to » “micro-conversion” and label » equals to » “pdf-view”
    4. Save.

You can You can now track PDF views as a goal within this Google Analytics view.

 

How to view PDF downloads in Google Analytics 4

To view file downloads, log in to your Google Analytics 4 account and select the website where you’d like to track file downloads.

If you’ve enabled downloads tracking as page views, you can find out the downloads report in the All Pages report along with other blog posts and pages.

This report can be accessed by navigating to Behaviour » Site Content » All Pages.

If you’ve enabled downloads tracking as events, you can see the downloads data in your events report.

In your event reports, navigate to Behavior » Events in the left panel. You’ll now see four different options.

    • Overview: It gives you a summary of top events data of your site

    • Top Events: It shows you a list of events that keep your visitors engaged on your site

    • Pages: It shows you a list of pages in which your downloadable resource is hosted. In other words, it is a list of posts and pages where the events occur on your site.

    • Events Flow: The events flow report helps you discover which events keep your visitors engaged with your site. It also visualizes the path users take from one popular event to another.

To get a detailed report, click on Top Events.

Then, click downloads to get a detailed report.

If you would like to see the full report on your Tag Manager events, click on the Behavior –> Events –> Overview report in the sidebar of Google Analytics. The Event Action report will show you the exact URLs of the downloaded PDFs.

Need help with how to track PDF downloads in Google Analytics 4?

If you’re still stuck and can’t track PDF downloads in Google Analytics 4, leave a comment below and we’ll see if we can help.

You can also contact Empower to find out more about our Insights & Analytics services if your organisation needs an extra hand in understanding the data from your website visitors.