How to Track PDFs using Google Analytics and Google Tag Manager

Posted by | Comments

Tags:


track pdf with google analytics and google tag manager

Google Analytics is a fantastic tool, but it’s not without its quirks. Perhaps one of the biggest ones is that GA does not track PDF clicks by default.

That’s something relatively glaring that is missing from the tool.

PDF tracking is baked into some of the paid web analytics tools in the market, which makes it extra annoying for marketers who would rather use GA, but would like to assess the performance of the entire site, including documents.

Technically, PDF tracking has been available for GA in the past, but each link on the web site needed to be tweaked to contain an event script. That’s both time-consuming and error-prone, so very few marketers took the time to do that.

Thankfully, that’s no longer the best solution to the PDF tracking problem on GA.

Tag Manager to the Rescue

If you have Google Tag Manager or GTM running on your site, you can use firing conditions to track PDF clicks. (If you’re on the fence about adding GTM to your site, here’s our guide about whether or not GTM is right for you.)

Not sure if Google Tag Manager is right for you?

Click here to read "Should You Be Using Google Tag Manager?"

We’re keeping this as simple as possible, so more marketers can use it as a guide, but the truth is GTM does introduce some measure of technical complexity. Here’s the least you need to get familiar with:

  • Variables: these are the attributes you can pull data from, like click URLs.
  • Triggers: these are the conditions under which you’ll get scripts to fire. So for PDF tracking, you’ll need some way to tell the system to fire the tag if the URL contains .pdf.
  • Tags: these are the beating heart of GTM. Tags are the things that fire when certain conditions are met, allowing you to do things like track PDF and mailto clicks, add general scripts like those for web analytics and survey tools, etc.

For PDF tracking on GA, let’s start with the variables.

Variable Setup

You need to make sure a few variables are available for your trigger and tag later. Let’s start with the click variables.

Go to Variables under the GTM interface, then to “Configure Built-in Variables.” Then, make sure the elements under “Clicks” are active:

variables click url

Under the same area, you will also find “Pages” variables. You’ll need “Page Path” to be active, but go ahead and activate everything under “Pages” as well.

Finally, we’ll need a custom variable called click path.

Near the bottom of the variables section, create a new custom variable, and follow this setup:

variables click path

Once you save “Click Path,” you’re done with variables - now it’s time to build the firing condition for PDFs.

Trigger Setup

Go to the Triggers section of GTM, and create a new trigger.

Set up the trigger like this:

trigger pdf click

  • “Click - Just Links” tells the system that it should listen for clicks on all elements of the site
  • “Wait for Tags” and “2000” tell the system to wait 2 seconds to listen for the click, in case there’s a lag. Adjust the 2000 value as needed
  • “Page Path” and “.*” tell the system to enable listening for this trigger everywhere
  • “Click URL,” “contains,” and “.pdf” tell the system to wait for a PDF click to fire the trigger

Name the trigger something that’s easy to remember, save it, and then move on to the tag.

Tag Setup

You’re almost there.

With the variables and the trigger out of the way, it’s time to configure the tag.

Go to the tags section of GTM. From there, create a new event tag, label the category something easy to remember, like PDF Click, have the action pull your custom variable, “{{Click Path}}” and add the tag you just created.

The whole tag should look like this:

tag track pdf clicks 1

Some caveats:

  • You’ll need to know whether you have Classic or Universal GA – this is what it would look like for “Classic”
  • You can insert your Web Property ID for Google Analytics manually too - this just uses a variable for the Google Analytics ID

Let’s zoom in a bit on the configuration screen:

tag track pdf clicks 2 components

“PDF Click” and “Click Path” have been explained above, but the “False” value under “Non-Interaction” tells the system to treat clicks to PDFs pretty much the same way pages are treated. That is, if people land on your page then click on a PDF, that interaction will not register as a bounce - that’s pretty important if you want bounce rate to be accurate.

Save the tag, publish the changes, and you’re done.

Somewhat Technical, But Powerful

Google Tag Manager isn’t for everyone.

And it is a somewhat technical tool. You can certainly get away with doing basic stuff like adding the GA code on your site without developer-level knowledge - but to get the most out of the tool, you’ll either need to pick up some script skills, or have a developer on hand to consult with.

That said, it’s not like GTM is a tool you’ll constantly be tweaking. PDF tracking is a pretty good example of GTM being a setup-and-forget mechanism - you’ll have to do some heavy-lifting, but you’ll only have to do it once.

If you have the technical knowledge in-house to attempt the steps above, you’ll be able to increase visibility for good, without adding a penny to your tools budget.

'Want to optimize your conversion funnel but don't know where to start? Find out how we can help you with conversion rate optimization