Updated March 3, 2023
When a visitor comes to your website, they leave behind their trail of online behavior through data that shows what content they engaged with and for how long.
Marketers are able to then gather this data and create a story about each individual consumer and their purchasing decisions and behavior.
[To find out how to track different conversions and goals in GA4, please reference our step-by-step tutorial.]
What Does This Mean for Marketers?
With the rise of digital content consumption, marketers are increasingly providing premium content offers that are downloadable to the visitor’s computer in the form of a PDF file.
If your site is offering these resources to visitors, you’ll want to know if visitors are actually downloading them. On the surface, Google Analytics doesn’t support file downloads in the form of tracking.
Now, with the help of Google Tag Manager or a little bit of coding, marketers can track this information. Check out our two preferred methods below.
How to Use Google Tag Manager
Google Tag Manager allows you to add “tags” to your website where necessary that connect with Google Analytics. Simply follow the steps below.
Step One: Install Google Tag Manager
Head over to Google’s page for setup and installation to begin installing Google Tag Manager. After the installation, familiarize yourself with its three main components.
- Rule – A set of conditions
- Tag – Flags an event where a condition is met
- Container – holds all of your set conditions and tags
Step Two: Enable a “Link Click Listener” Tag
Next, you’ll want to click on “Variables” in the left panel navigation and click “Configure” under the “Built-in Variables” section. Make sure that “Click URL” is checked under the “Clicks” section.
Step Three: Create a Tag
- Click on “Tags” in the left panel and click on “NEW” and name the tag accordingly
- Configure your tag by clicking on the “Tag Configuration” section
- Next, choose “Universal Analytics” as your tag type
- Set Tracking ID (from your Google Analytics account) and Tracking Type to “Event”
- Event tracking parameters
- Category – Resource Download
- Action – Download of the PDF
- Label – {{Click Text}}
Step Four: Create a Trigger
- Click on the edit icon in the “Triggering” section
- Click add (New) to create a trigger and name accordingly
- Configure the trigger
- Choose “Just Links” as your trigger type under the “Click” section
- Set up your rule with the dropdowns and text fields: “click URL” “contains” “.pdf”
- Save the trigger and save the tag
Step Five: Publish and Test
Congratulations! You made it this far. Finally, click the “Publish” button in the top right to publish your event. Now that your tag is set up, you’ll want to test it to ensure that it’s working as it should be.
Try opening an additional browser, logging into Google Analytics, and clicking on the PDF download on your live site to enable the event. Switch to your Analytics browser and view “Real-time events.” You should be able to view the event tracking analytics.
What Does This Track?
Now that you’ve enabled the tag and track function of your PDF file, there’s plenty that you can see, including:
- The PDF’s page views
- Unique page views
- Average time on page
- Bounce rate
- Links to the PDF
- Origin of these links
How to Use Event Goals (and Some Code)
Another way you can track clicks to PDFs is by inserting the event code into the link to your PDF.
This method is perfect for those who have a little bit of coding experience and have the ability to edit the source code of the page they want to edit.
Check out the simple steps below.
Step One: Add Event Tracking Code to Your Link
Now, depending on the type of analytics code you have on your site, there are two ways to add the code.
Example Analytics.js code:
<a href=”/images/mypdf.pdf” onclick=”ga(‘send’, ‘event’, ‘PDF Download’, ‘Click to Download’, ‘Download the PDF ‘, 0);”>Download the PDF</a>
Example Global Site Tag (gtag.js) code:
<a href=”/images/mypdf.pdf” onclick=”gtag(‘event’, ‘click’, { event_category: ‘PDF Download’, event_action: ‘Click to Download’, event_label: ‘Download the PDF’});”> Download the PDF</a>
Step Two: Test the Link in Realtime Events
Have your webpage and Google Analytics open in two different tabs, and navigate to Realtime > Events in Google Analytics.
Now, go back to the page you added the code to, and click the link to download the PDF.
After doing so, switch back to Google Analytics to see if the event is coming through in real-time.
Note: If you don’t see the event trigger, be sure to check your code on the page and see if you missed any pieces such as quotations, apostrophes, commas, etc.
Step Three: Create an Event Goal
Once the event starts to come through in analytics, if you want to use PDF downloads as a goal conversion, this next step is quite simple.
In Google Analytics, navigate to the goals area: Admin > Goals. Create a new goal and select “Custom,” and then the type of goal as “Event.”
Then, you are going to fill out the fields with whatever information you used in the event code on the webpage: Save the goals and then see the results come in!
How Can You Learn More?
We hope this helps your efforts to better market to the needs of your website visitors and users!
To dive deeper into tracking PDFs in Google Analytics, check out this helpful post from Moz. And be sure to check out some of our other insightful posts:
- How to Remove Illegitimate Referrals in Google Analytics
- 4 Things You Should Be Tracking in Google Analytics
- Was Your Site Hit by Bot Traffic Recently?
- How to Track LiveChat Leads in Google Analytics
If you have any additional questions, as always, please contact the Sixth City Marketing team. We’ll be happy to help!