Tracking PDF Downloads with Google Tag Manager

Posted on February 6th, by Jay Murphy in Digital Marketing, Google Tag Manager, Universal Analytics. 14 comments

Use Google Tag Manager’s new user interface to track PDF Downloads

The new version of Google Tag Manager is a lot easier to work with – no more triggers, listeners and rules…  They are all combined into triggers.  Two of our favorite Tags we setup in the old version of Google Tag Manager were tags to track PDF downloads and tags to track outbound links.  We will step through how to setup each of these in the new user interface for Google Tag Manager.

Setup Variables

First out of the gate we want to setup a tag in Google Tag Manager (GTM) that fires Google Analytics Event when a user on our website clicks on a PDF link.  To begin this setup we will login to GTM and within your container open up the Variables tab. Now turn on the Click Variable “Click URL” and “Click Text”.  The “Click URL” is the Variable we will be using to identify a click on a PDF link in our trigger.  And we will use the “Click Text” variable for building our Google Analytics Event Tag.  (The “Click Element” could be used instead of “Click URL” – my preference is for “Click URL”, let me know your thoughts on this…)

select variables in new google tag manager ui

Create a PDF Link Click Trigger

Next we need to set up our Link Click Trigger this way to track PDF downloads.  First select

Create a Trigger

Select the ‘Click’ trigger from the type and then specify a ‘Link Click’.  This creates code that will listen for when users click on a link, next we will tell the trigger to fire when the link is to a PDF file.  We do this by setting up a rule:

Click URL

matches RegEx (ignore case)


Google Tag Manager - PDF Trigger

Let’s break this trigger down, we want it to fire when our click URL ends with the characters “.pdf”.  We do this by selecting the “click URL” variable.  Next we choose to match using a regular expression and be cause we want to track files names regardless of whether or not there are capitals we select “matches RegEx (ignore case)”.  Finally we create our regular expression – “.pdf” is the text we want to match in our Click URL – because “.” is a special character in regular expressions we have to escape it with the “\” character.  And then to wrap it up we use the “$” character to indicate that the match should come at the end of the URL.  To learn more about regular expressions check out this tutorial –

Build a PDF Universal Analytics Event Tag

OK now we have a trigger for the PDF download, now we need a GA event tag to complete our task.  So we create a new tag – select GA, then universal analytics , insert our UA code and then select event.  For the event we set the category to PDF, action to download and the value to the {{Click Text}}.  Select our PDF Download Trigger and we are ready to test!  It will look like this:

PDF Download Tag in Google Tag Manager

You can do this by turning on the Preview/Debug mode in GTM and then click on a PDF on your website.  When it works you will see this in the debug area on your browser:

PDF Tracker Tag - Google Tag Manager

Publish your new version of the container and congratulations you are tracking PDF downloads on your website.  (If this is not working check for typos in the regular expressions or links that do not end in “.pdf” to start.)

Be Sociable, Share!

14 thoughts on “Tracking PDF Downloads with Google Tag Manager

  1. Thank you for sharing this helpful information. Glad I stumbled upon your article, it saved me much headaches.

    One quick question. After reviewing my analytics in real time, I’m not seeing it come up as a hit. Is this normal?

  2. Hello I try to setup tag manager for PDF download but I don’t get success.
    Previously I used Download for PDF download tracking but now which code we at in href for tracking the pdf download.

    • Hi Mohit: For the tracking to work as outlined in this post your link URL needs to contain a link to a pdf file. the URL has to end in “.pdf”. So it will look like this:

      Best – Jay

    • Hi Nicolas:

      We show Click URL in the label, Click URL points to the file name and path of the PDF file. We use this to differentiate between multiple PDF files. You could also use Click Text if that is unique for a PDF. Here is a quick example of what these parts of a link are:

      • ‘download/whitepaper-Jul2015.pdf’ is the Click URL, and
      • ‘Download our White Paper’ is the Click Text

      I also leave non-interactive to False this means when the event is sent back to Google Analytic the time information is also updated and more importantly user that download a PDF from a single page visit will not show as a bounce. If you set non-interactive to True then the time information is not updated. For more information view this link –

      All the Best,

  3. Pingback: Tracking Outbound Links with Google Tag Manager | Trionia

Leave a Reply

Your email address will not be published.

wordpress Wordpress Theme