How to Track PDF Downloads With Google Tag Manager

Elliot Sheen
Written on April 15, 2020, Last updated on May 7th, 2020
7 Mins

If you have a number of PDF resources on your website, chances are you’re going to want to track downloads of these. Using Google Tag Manager makes tracking setup a breeze.

By using Google Tag Manager’s variables, we can create “one tag to rule them all“, passing the specific PDF name dynamically based on the content downloaded.

In this article we’re going to run through how to track PDF downloads using Google Tag Manager and how to set this as a conversion in Google Analytics, Google Ads, Facebook Ads, Linkedin Ads and Twitter Ads.

PDF Tracking in Google Tag Manager

Create Your Trigger

  1. From the Triggers menu select New
  2. Give your trigger a descriptive name, we’ve gone for PDF Download Tracker
  3. Select the trigger Click > All Elements
  4. Under “This trigger fires on” select Some Clicks
  5. Select Click URL from the variable drop down
  6. Select Ends With from the match type dropdown
  7. Specify .pdf in the value field

The resulting Trigger should look a little like this:

Track PDF Downloads Tag

This trigger will fire when the clicked elements links to a URL ending in .pdf

 

For the Trigger, our work here is done. When added to a tag this trigger will fire when the URL of a clicked element ends in .pdf. This will work if you are linking to PDF’s from text, images or buttons.

Track PDF Downloads in Google Analytics

  1. From the Tags menu select New
  2. Give your tag a descriptive name, we’ve opted for GA – PDF Download
  3. Select the Google Analytics: Universal Analytics tag
  4. Select Event as your “track type”
  5. Set your Category and Action names – these can be anything of your choosing
  6. Set the Label to the {{Click URL}} variable by selecting the building block icon
  7. Under Triggering, select the trigger we created earlier and save
  8. To push live, hit Submit, provide some details about the changes you made in this version and press Publish

Some notes on getting the most out of your data. When it comes to Event Category and Action, set values that make sense for your Google Analytics setup and your businesses website.

For example: we’ve opted for Resource and PDF Download as we have other resource types such as videos and scripts that we’d like to be categorised under the Resource banner.

We’ve chosen to set the label, the lowest and most specific level of Google Analytics’ Event hierarchy, to the Click URL variable. This will pass the URL of the PDF into Google Analytics, allowing you to see the exact file accessed.

Remember if you’d like to set this PDF analytics tracking as a goal also, you can do so by setting the exact Event Category and Action you have above and leaving Label blank.

Google Analytics PDF Tracking

Tracking PDFs in Google Analytics

 

Track PDF Downloads in Google Ads

  1. From the Tags menu select New
  2. Give your tag a descriptive name, we’ve opted for GAds – PDF Download
  3. Select the Google Ads Conversion Tracking tag
  4. Next we need to navigate to the Google Ads account in question
  5. Select Tools & Settings from the header bar and then Conversions under the measurement section
  6. Click the blue + icon
  7. Select Website conversions
  8. Select a conversion category, we’ve chosen Other
  9. Name your conversion, we chose PDF Download
  10. Select Use the same value… and insert the value a PDF download is worth, or, select Don’t use a value…
  11. Chose your count options, if you’d like to track every time a PDF is downloaded following a paid click select Every
  12. If you’d like to track one conversion (PDF download) per paid click select One
  13. Chose your Conversion Window (post click) and view through window settings
  14. Select whether you would like PDF Downloads to be included as Conversions – note this data will fuel any automated bidding strategies if you select Yes
  15. Select your attribution model
  16. Click Create and continue
  17. Important – Google often prompts you to enable Enhanced CPC at this point – leaving this enabled will switch all campaigns onto eCPC
  18. Select Use Google Tag Manager from the install options list
  19. Copy your Conversion ID  and paste this into the relevant box in your new tag in Google Tag Manager
  20. Repeat this process for Conversion Label
  21. You can now click Next and Done in Google Ads
  22. Return to Google Tag Manager and under Triggering, select the trigger we created earlier and save
  23. To push live, hit Submit, provide some details about the changes you made in this version and press Publish

Unlike Google Analytics, Google Ads conversions don’t have hierarchal structure that allows you to pass additional data.

You will of course be able to see the specific PDF’s downloaded based on the Google Analytics tag above and by ensuring your Google Ads & Google Analytics accounts are linked and sharing data.

Track PDF Downloads in Facebook Ads

  1. From the Tags menu select New
  2. Give your trigger a descriptive name, we’ve opted for FB – PDF Download
  3. Select the Custom HTML tag
  4. Copy and paste the below cod
  5. Under Triggering, select the trigger we created earlier and save
  6. To push live, hit Submit, provide some details about the changes you made in this version and press Publish
<!-- Facebook Pixel Code -->
<script>
fbq('track', 'ViewContent', {
  content_name: '{{Click URL}}',
});
</script>
<!-- End Facebook Pixel Code -->

This code utilises the Facebook Pixel’s built in ViewContent event and dynamically inserts the PDF URL using the Click URL variable. This will allow you to specify whether conversions within Facebook should be based on all or specific PDF downloads.

You will need to have your core Facebook Pixel in place across your website in order for the above code to work!

Track PDF Downloads in Linkedin Ads

  1. From the Tags menu select New
  2. Give your tag a descriptive name, we’ve opted for LI – PDF Download
  3. Select the Custom HTML tag
  4. Within your Linkedin Ads account navigate to Account Assets > Conversions
  5. Click Create a conversion
  6. Give your conversion a name
  7. Select Download as your conversion type
  8. Enter a value of this conversion, this is optional
  9. Select your attribution settings, how many days following a click and a view would you like the conversion to attribute
  10. Select your credit settings, would you like the last interaction for every campaign to track conversions or only the final campaign
  11. Under Step 2, select the campaigns that you’d like to track this new conversion
  12. Under Step 3, select Use an event specific pixel
  13. Copy the code generated below
  14. Return to Google Tag Manager and paste the code
  15. Under Triggering, select the trigger we created earlier and save
  16. To push live, hit Submit, provide some details about the changes you made in this version and press Publish

 

Linkedin Ads PDF tracking tag

Linkedin Ads PDF tracking tag

Track PDF Downloads in Twitter Ads

  1. From the Tags menu select New
  2. Give your tag a descriptive name, we’ve opted for TW – PDF Download
  3. Select the Twitter Universal Website tag
  4. Enter your Twitter Pixel ID
  5. Under “Select tag event” choose ViewContent or Download
  6. Within the “Event parameters” section, click Add
  7. Select content_name as the “Event parameter name”
  8. For the “Value” select the Click URL variable using the building blocks icon to the right
  9. You can repeat this step setting content_category as a fixed value of PDF
  10. Under Triggering, select the trigger we created earlier and save
  11. To push live, hit Submit, provide some details about the changes you made in this version and press Publish

 

Tracking PDFs in Twitter Ads

Setting up your Twitter Universal Website Tag to track PDF downloads

 

Testing Your Tracking

Once you’ve implemented the tags that are relevant to your business, it’s time to test they’re working. For this we’re going to use Google Tag Manager’s preview mode.

  1. Within Google Tag Manager’s Workspace section, select Preview from the top right
  2. Next navigate to the page of your website with the PDFs in question
  3. You should see the Preview Window at the bottom of the page
  4. Click on the PDF’s you’re tracking whilst holding down CTRL or Command – this will open the PDF in a new tab
  5. Note in the preview window we’re looking for our Tags to move from the Not Fired on This Page to the Fired on This Page section of the preview window

Congratulations, your GTM PDF download tracking is complete!

If your tags are still sat under the Not Fired section, well, we need to do something about that.

Fixing Trigger Issues

Fortunately as all of our tags are based on just one trigger, we simply need to check and potentially fix this.

  1. Within the Google Tag Manager preview window you will see Clicks appearing in the Summary column to the left
  2. Click the PDFs you’re looking to track again whilst holding down CTRL or Command – this will open the PDF in a new tab
  3. Note in the Summary column the latest click that will have appeared at the top of the list, select this
  4. Select the Variables tab
    Track PDF Downloads Tag

    Variables Tab in Google Tag

     

  5.  Scroll down until you see the Click URL variable

This list shows the variables based on your recent click to download a PDF. If your tags did not fire during testing, it is likely due to the fact that your Click URL did not end in .pdf as we specified.

As variable values in this list will be unique to your website, this is where we put your tracking knowledge to the test. Within the list try and isolate some variables that are unique to PDF downloads. Ideally we’re looking for the file URL or file name containing .pdf.

Once you’ve found a variable that is unique PDF downloads, we need to return to Google Tag Manager and edit our One Tag to Rule Them All.

Use the variable you’ve identified in the above steps and set it as the rule for the trigger. Note you will need to change this variable in the Google Analytics, Facebook and Twitter tags above also as these pass the dynamic data.

Once you’ve done that, repeat the testing steps.

 

Happy tagging folks! By combining Google Analytics Events and the various media platforms conversion tags the resulting data contains both details on specific content downloaded as well as the vital conversion data needed to influence your bidding, budgeting, testing and optimising.

A Wise Sam once said “It’s the job that’s never started that takes the longest to finish”, so go get tagging!

If you have any issues with tracking PDF downloads, let us know in the comments and we’ll happily help out.

Hobbits clapping

One Tag to Rule Them All

1 Your business
2 Your website
3 Get proposal
  • WHAT TO EXPECT

    Tailored Insights

    Competitor Analysis

    Custom Pricing