Learn Tracking PDFs with Google Tag Manager - ByteScout
  • Home
  • /
  • Blog
  • /
  • Learn Tracking PDFs with Google Tag Manager

Learn Tracking PDFs with Google Tag Manager

The PDF (Portable Document Format) is one of the most important file formats. It is heavily used in various companies and industries for various purposes such as creating and sending reports, sales reports, documentation, and much more. Sometimes it becomes really difficult to track PDF files. To overcome this, there are various ways with the help of which one can track PDFs. Google tag manager is one of the solutions that can be used to track PDFs.

Many websites allow downloading of marketing supplies like whitepapers or reports. These usually come in the structure of a PDF. In many instances, marketers need to track these downloads. They can take marketing conclusions based on investment in the content. Google Analytics traces page views by using a tracking pixel on an HTML page.

Tracking a PDF download goes a bit contrarily since a PDF file cannot demand a tracing pixel. Fortunately, with the aid of Google Tag Manager, there is a simple method to follow this data. First, let’s take a look at What is Google tag manager.

  1. What is Google Tag Manager
  2. How to track PDFs with Google Tag Manager?
  3. Configure the right built-in variables.
  4. Create Click Path
  5. Create a Trigger
  6. Create a Tag
  7. Testing
  8. Advantages and Disadvantages of Google Tag Manager
  9. Elements of tags and GTM
  10. Conclusion

What is Google Tag Manager?

Google Tag Manager is an easy-to-use tool that enables users to operate and expand marketing tags like pieces of code or tracking pixels on the website without having to change the code. Here’s a very easy illustration of how GTM operates. Data from one website is distributed with Analytics through Google Tag Manager. GTM becomes extremely helpful when you have heaps of tags to maintain because all of the code is put in one place. Now how this tool can be used to track the PDF file is the question. 

Google Tag Manager (also identified as GTM) is a tag control solution presented by Google. Using this  ‘online tool’, one can use and maintain multiple marketing and analytics tags on a website or mobile app. Let’s take a look at it.

By using the GTM user interface, users can insert, manipulate, enable, disable or eliminate any tag, with just some clicks. You don’t have to hard code just for using and managing multiple tags.

How to track PDFs with Google Tag Manager?

Tracking PDFs on the website can assist you to understand what drives your visitors.  Google Analytics does not implicitly track PDFs activity. Users must configure Google Analytics to track downloads implicitly. Depending on the website’s structure and its resources, there are plenty of alternatives for tracking PDF file downloads. Let’s look at how this tracking operates in Google Analytics. The following are the steps:

1. Configure the right built-in variables

Google Tag Manager

Now the first step is: Just Log into Google Tag Manager and locate the container of the domain. Now click on ‘Variables’ on the list appearing on the left-hand. Here you can configure which variables you’d want to operate with when building the tag.

Furthermore, if you are utilizing Google Tag Manager then you can follow clicks on ‘submit’ buttons inserted on pages over the website quickly. Without applying GTM, you will have to add an event tracking code, to every, submit button. This is extremely time eating and inclined to errors.

2. Create Click Path

Google Tag Manager Tips

Now the goal of this variable is to configure the page path of the PDF’s URL. For this, just click the red “New” button in the User-Defined Variables segment and name this new variable “Click Path.” Below Choose Type, click the 2nd alternative, “Auto-Event Variables.” Set the Variable Type “Element URL” and the “Path” will be the Component Type.

3. Create a Trigger

Now here, below Choose Event, choose “Click.” This is because we want to track PDF clicks. After that below, Configure Trigger, choose “Just Links” and uncheck the “Wait for Tags” and “Check Validation”. After that below Fire On, choose “Some Clicks.” Then set the trigger to shoot when “Click URL pairs with Regex\.pdf” This guarantees the tag shoots only when users click PDFs links.

Google Tag Manager Tools

4. Create a Tag

Now, create your tag. Here you have to determine what information to send to Analytics when your trigger is discharged. For this, Click ‘Tags’ on the left side and choose to create a new tag. Below the Choose Product, choose Google Analytics after that select a Tag Type. Now add your Tracking ID, and then choose “Page View’ below Track TypeUnder Configure Tag.

After this add the Tracking ID. Now, under More Settings, select Fields to Set, name the Field “Page” and configure the value as the variable we created as Click Path in the above steps. This move sets the tag to give the PDF’s URL page route or path to Analytics and presents it as the “Page” variable.

A tag is a collection of JavaScript code that is applied to accumulate analysis and marketing data from the website/mobile app and then transfers that data to 3rd party help like Google Analytics, Google Adwords, etc.

There are various ways. The tag is simply a piece of code. Users can add this piece of code or tag directly to the website, or by inserting it in the website template files such as header.php or users can insert the tag on their website, via Google Tag Manager (GTM).


Now that everything is properly configured you can test to assure it is operating correctly. For this, open two windows in your browser. In one tab, open your website, and in the other tab open your Google Analytics account. Now, click on the PDF download on the website to trigger the function. Now to test, go to the Google Analytics window and click on ‘Real-time events’. This will display the event tracking analytics. Here you will find all the downloads of your PDFs from your website.

Advantages and Disadvantages of Google Tag Manager

The most important advantage of Google Tag Manager is that it makes it more straightforward for users to gain tags without having to depend on programmers to create them. Since Google Tag Manager allows users to avoid affecting the source code, users can instantly add and make modifications to tags. This is a significant benefit if, for instance, users only want to utilize a tag to obtain data for a short time. Without GTM, there’s a great possibility that it would take too much time for the tag to be attached.

One disadvantage with conventional tracking tags is that if they work at the same time then they can slow down website activities. When tags work at the same time, the slow-performing tag slows down all the other tags that are depending on it. But tags designed in GTM load at the same time by default, implying each tag can load and work anytime it’s available. If users want to constrain the region in which their tags are fired, there is a tag indexing and firing preference feature that can be used to accomplish this.

Elements of tags and GTM

  • Container: A container is responsible for “holding” all the tags of the website. After forming a unique container, GTM allows users to add some code to their website. The container code needs to be inserted into the source code so it unfolds on each page of the website.
  • Triggers:Each tag on a website has a particular goal. For example, users want to have a tag that will transfer data when someone downloads a file, when someone clicks a link, or when someone submits a form. These types of conditions are triggers and all tags are assigned one trigger. If triggers are not their then tags will never work.
  • Variables: While tags are based on triggers, triggers are based on variables. Variables include the utility a trigger demands to decide to understand whether or not it should run. The tag links the utility of the variable to the utility described in the trigger and if the variable matches the requirements of the trigger, the tag will run.

Tags also utilize variables to get data that can be transferred onto the datasheet as a user communicates with the website. A typical case of this would be if a tag was configured to run when a user inserts a specific amount of stocks into their shopping cart.


The most important benefit of using GTM is that it offers high-level analytics of PDF tracking possible for the website. GTM gives several in-built tags and variables through which one can execute high-level tracking in a short period. The identical job may need many days or weeks without GTM. With the help of GTM, if properly configured, PDFs can be tracked and can be analyzed.


About the Author

ByteScout Team ByteScout Team of Writers ByteScout has a team of professional writers proficient in different technical topics. We select the best writers to cover interesting and trending topics for our readers. We love developers and we hope our articles help you learn about programming and programmers.