How to track PDF downloads using Google Tag Manager
What’s the best way to track PDF downloads on your website?
I’d recommend using Google Tag Manager to create a custom event, and then tracking the event in Google Analytics.
Click on the image below to download an example Google Analytics PDF
The PDF should open in a separate tab.
Below I’ll show to track PDF downloads in Google Analytics using Google Tag Manager.
How to create a PDF download tag in Google Tag Manager
Click New Tag in Google Tag Manager.
Choose the tag type of ‘Google Analytics – Universal Analytics’.
Added in the following details to the tag. Choose your own Google Analytics tracking code.
By adding in {{Click URL}} as our Label, we will be able to track each unique PDF download on the website.
Create a trigger using the details below. Choose the Trigger Type ‘Click – Just Links’.
Set up the trigger as shown in the image below.
For the Page URL you can use ‘matches Regex’ and .* to select all pages.
For the Click URL, we can choose ‘ends with’ and ‘pdf’ so that the trigger works only with pdf downloads specifically.
We have our ‘GA – PDF Download’ tag which is triggered by the ‘PDF Download Clicks’ trigger.
Testing out the tag using Google Tag Manager preview mode
Once we’ve set up the tag and the trigger, we can test out whether it’s firing.
Earlier in this blog post I clicked the PDF download image, as shown below.
I could then see in the GTM preview mode that the ‘GA – PDF Download’ tag had fired.
Confirming the events are appearing in Google Analytics
We can open up Google Analytics and look at Real-Time Events.
We see that under Events there has been a Download Event and the Event Label is our PDF URL. This confirms the GTM tag is firing correctly.
Since we can see that the tag is working correctly and the data is appearing as we want it to in Google Analytics, we can go ahead and publish the latest workspace version in Google Tag Manager.
Download Google Data Studio Templates
If you’d like to download one of my Google Data Studio reports as a template to use for your own data, you can visit Data Studio Templates and purchase one.
My other GTM blog posts
If you liked this article you might like my other blog posts about Google Tag Manager.
Or you can follow me on Twitter!
Thank you Michael. I have looked at countless Google Tag Manager tutorials and yours was the one that finally got it working for me!
Thanks so much April! 🙂 Glad it was useful. Have written another one where you can track multiple different types of file downloads using one tag. Maybe you might find it useful! https://michaelhoweely.com/2019/05/30/how-to-track-file-downloads-using-google-data-studio/
Thank you very much, this step-by-step introduction is amazing. However, I have one more question. When I email links to a PDF, these views will not appear in Analytics. Do you have a tip for that?
I would create a custom URL to the PDF using Campaign URL Builder – https://ga-dev-tools.appspot.com/campaign-url-builder/
Hi Michael. I managed to setup this up very quickly. Can this be tracked in GA so that I’m able to tell the number of times the event has fired over a period of time?
Yes absolutely. If it is setup correctly the events will appear in Google Analytics. You can test this out by looking in Google Analytics > Real time > Events. You must use an unfiltered view of your site so that your own IP address is not excluded. But if you click file downloads you should see the events appearing in Google Analytics.
Hi Michael
This is the first tutorial I have found on this that makes sense to me. I’m coming up against an issue though. {{Click URL}} now seems to be an unknown variale so I’m wondering which one I should now be using for this?
Thanks Al glad it makes sense!
Have made sure you’ve added Click URL as a variable?
In GTM go to Variables then click ‘Configure’ then make sure Click URL is ticked.
Have you done this?
Hello, how do I configure my Goal so it tracks pdf downloads ? I used {{Click URL}} as label but it doesn’t work. Everything works in Events tab but my Goal shows zero pdf downloads.
I want to monitor two links on my index page. I have Google Analytics. I have GTM, also. I created a tag with the Universal Analytics (not sure why I chose this). Track Type: Event; Action: Click URL. I click preview and then publish. But nothing happens. No data is set back to Analytics->Event. I tried any clicks and still nothing. I feel I’m missing some step. I’m not sure how the GTM tag actually can monitor events on the web site.
Two things confuse me. The first is how does the local development of the tag on my computer end up on the web site? But also, when I look at GTM on my computer, and I see Action or Label or Value, clicking on the +symbol takes me to the same list, which is Choose a Variable. This doesn’t make sense to me.
Thanks, Michael! I have an Atlassian Confluence site and it can be dicey setting up Google Analytics and Tag Manager correctly. This page got me tracking downloaded files without a lot of hassle.
That’s great – thanks so much for letting me know Steve! 🙂
Hi Michael, thanks for this info, although for me it seems to work for opening PDFs but not for someone who ‘saves as to download’. Is there any way to track actual downloads of PDFs rather than opening in browser. Thanks.
Hi PJ, good question.
I’m not 100% sure how to do set that up if someone right clicks and selects ‘Save As’.
Category and action are wrong. You mixed them up.