BenCo-Founder15 August, 2023 • Reading time: 8 minutesHow to track PDF downloads in Google Analytics 4Set up Google Analytics 4 to properly track PDF downloads on your website. Analytics
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 areFind out which content type you should offer more and which aren’t getting downloaded muchSave your time and money by only producing the PDF content your audience actually wantsIn 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 MethodIn 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 linkIf 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 pluginMany 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 ManagerIf 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 conditionsTag – Triggers an event when a rule is metContainer – the “box” that holds all your rules and tagsBefore 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.In your Container Overview menu click New » Tag and name the tag “link click listener”Under “Tag Type” select Event Listener » Link Click ListenerOn the right hand side of the screen, click “+Add” next to “Firing Rules” and select “All pages”Google Tag Manager creates the “All pages” rule automaticallySaveThis 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 ManagerNow 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.In your Container Overview menu click New » Rule and name the rule “PDF click”Under “Conditions” select {{event}} » equals » gtm.linkClick.Remember, gtm.linkClick is the item generated by your Link Click Listener tagAdd another condition – {{element url}} » contains » .pdfSaveThis creates a rule that is only met when someone clicks on a link with .pdf in the url string. PDF Click in Google Tag ManagerNext 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.In your Container Overview menu click New » Tag and name the tag “Analytics Event – PDF View”Select “Tag Type” Google Analytics » Universal AnalyticsAdd your Google Analytics tracking ID to the “Tracking ID” boxUnder “Track Type” select EventIn the “Event Tracking Parameters” assign the following names. These will help organise events within Google Analytics as you add more tags):Category – micro-conversionAction – {{element url}}Label – pdf-viewClick “+Add” next to “Firing Rules” and select “pdf click”SaveNow you’ve installed the tag, you can test they’re working using the following step-by-step:In the upper-right corner of your Container Overview menu click Preview » DebugVisit your website in a new tabClick on a PDF on your websiteIf the menu bar below reads “Tags Fired on this Page: Analytics Event – PDF View,” then you’re set.If not, go back and look for mistakes. A single typo or space can stop the tag from firing correctly.Exit debug mode. PDF view tag firing in Google Tag ManagerNow the tag has been added and tested as working correctly, you can create a “PDF View” goal in Google Analytics:In your Google Analytics account, select “Admin” from the primary navigation.Select the property (whose tracking code you used in Google Tag Manager) and the view you want to create the goal in.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”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 4To 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 siteTop Events: It shows you a list of events that keep your visitors engaged on your sitePages: 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.