Well you mask why we track PDF as pageview and not downloads or events, well the answer is simple, most of us nowadays are not really downloading pdf files on a website but rather we read the pdf file from the website using the native pdf reader that our browsers have.

This article will mainly focus on tracking PDF as pageview, but it will still give you insights if you want to track pdf link click as events.

Let us begin.


Activating Click Url

The pre-built variable that captures your visitors click url is the “Click Url” variable, and to activate it navigate to Variables and under Clicks check Click Url. See image below.

1 PDF Page view

Creating Our Trigger

Since we want to track pdf clicks only and not only clicks we must create some filters and rules to our triggers. As an overview please see image below:

2 PDF Page view

To create a trigger similar to the image above create a new Trigger and name it “PDF links Only”, and yes you can name any name you wanted.

Then, Choose Event as Click this is because we want this trigger to fire if someone is clicking on your website. On Configure Trigger select Link Click – of course because we only want to track link clicks and not all clicks. Please leave Wait for Tags and Check Validation as it is for now as we don’t need it, but you might need it on some triggers in the future.

Now lets’ refine our trigger more; under Fire On select Some Clicks and add the following filters or conditions Click URL, matches RegEx (ignore case) and \.pdf. The last part of the filter means that this trigger will enable when the URL contains PDF in it.

Ready for Tags

Now we set-up our Tags by creating new Tag via GTM interface. To make it more straightforward I will provide the screenshot again of the output:

3 PDF Page view

So basically what I did was:

  1. Create a new Tag and Name it “PDF Virtual Pageview”
  2. Choose Product as Google Analytics
  3. Choose Tag Type as Universal Analytics.
  4. Configure Tag – Input the Tracking ID and Track Type as Page View.

Now set the More Settings and Field to Set. On the File Name type in “page” and Value “{{Click Url}}”, it should look like similar to the image below:

4 PDF Page view

Lastly, fire the tags using the Trigger we created a while ago. See image below:

5 PDF Page view

More Fine Tuning

Before we publish your tag, well I’m thinking that we can still fine tune our Reports on GA if we can add more tweaks on our GTM tags. Instead of using the pre-built Click Url we want to use and Auto Event Variable and name it Click Url Path, well you can name it anything you want.

Access your variable page and then create new variable, simply follow the image below.

6 PDF Page view

After that let us change the Tag we created and the output should look like the image below.

7 PDF Page view

The second field is optional, the purpose of that is to include the Title of the link to your GA report. I put it optional because most of us are using “here” as anchor text to pdf links to our website, say “ Click here for the article”, and if all pdf anchors are the same then your data would not be more meaningful.

In lieu to this, you can have your own experiments in order to find way to include Titles on your PDF pages on GA reports; this part is for you to uncover.

Need help setting up PDF virtual pageviews? get in contact or get a free trial!

PDFs can often be turned into blog posts to help with SEO and rankings – if you have a number of PDFs consider updating them into blog posts. Move Ahead Media is an SEO company that can assist with this process and all other aspects of SEO.