How to Track PDF Downloads With Google Analytics 4

alt
Isabella Doyle Written on April 15th, 2020, Last updated on January 9th, 2024

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.

Privacy Breach Risk with PDF Downloads

Extra measures may need to be taken to ensure that Personal Identifiable Information (PII) isn’t collected inadvertently with pdf download tracking. If you have a functionality on your website that allows users to upload PDFs to an online portal, you are at high risk of breaching user privacy. In the past, we have seen users’ names and other PII data being collected within PDF titles.

If you have such a functionality on your website, you should add conditions to your trigger which exclude certain file downloads being tracked. For example, if users’ PDF files are accessible on a website subdomain (i.e. https://portal.mywebsite.com), you can add a condition to the trigger to exclude tracking downloads on this portal. For example:

Track PDF Downloads in Google Analytics 4

  1. From the Tags menu select New
  2. Give your tag a descriptive name, such as GA4 – PDF Download
  3. Select the Google Analytics: GA4 Event tag
  4. Under Configuration Tag, input your Measurement ID – find this within your GA4 Configuration Tag (or in your GA account under Admin > Property > Data Stream > Select Stream)
  5. Create the event name – this is how the event will appear in your GA property. Using file_download as the event name is good practice (see the section below to find out why!)
  6. Add in any parameters (additional bits of data) you wish to send along with your event such as the {{Click URL}} variable which is selected by clicking 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

If you want to track all downloads on your website, you can simply enable File Downloads in the Enhanced Measurement section of Analytics. Enhanced measurement is just one of the 4 event types in GA4 along with built-in, recommended, and custom events.

Both built-in and enhanced events are collected automatically. While built-in events are collected by default when the GTM snippet is added to your website, enhanced measurement events can be enabled within your GA account.

Some implementation is needed for recommended and custom events to appear in GA. For recommended events it’s good practice to use event names from their pre-defined list as doing so will ensure these events are included in enriched reports in the future.

Custom events are defined by you. However, they should only be created when no other event fits the bill as these events won’t appear in standard reporting. For meaningful analysis of custom events, it is vital you create custom reports in the Explorations section of 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 a hierarchal structure that allows you to pass additional data.

You will of course be able to see the specific PDFs 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 Tracking
  5. Click Create an online 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 the Insight Tag and track conversions by event
  13. Copy the snippet generated and press create
  14. Return to Google Tag Manager and paste the code
    Linkedin Ads PDF tracking tag
    Linkedin Ads PDF tracking tag

     

  15. To ensure the LinkedIn pixel has time to load, we use a time delay function of 1000ms (1 second) – see image above
  16. Next, go to Advanced settings > Set Tag firing options as ‘once per event’
  17. Under Tag Sequencing settings tick the following box:
  18. Go to Set-up Tag and select your LinkedIn Insight tag
  19. Under Triggering, select the trigger we created earlier and save
  20. To push live, hit Submit, provide some details about the changes you made in this version and press Publish

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, reach out to our team and we’d be happy to help out.

Hobbits clapping
One Tag to Rule Them All
alt
Isabella Doyle I’m Izzy – a newcomer to the Bind Team, I have the privilege of working alongside Josh on team tech. When I’m not deep in technical analysis – I enjoy getting out into nature, live music and exploring the unfamiliar. Life goal – dog collector!

Ready to supercharge your paid media?