Analyzing Downloads on your website can provide valuable insights into user behavior. With Google Analytics, you can track exactly which documents or files are being downloaded by your visitors. In this tutorial, I will explain step by step how to set up download tracking for PDFs in Google Analytics. This will not only give you data on the frequency of downloads, but also on the specific files that interest your users.
Key Takeaways
- The Google Tag Manager is an essential tool for managing download tracking.
- It is important to correctly identify the file type in order to conduct precise tracking.
- By properly configuring tags and triggers, you can analyze user behavior accurately.
Step-by-Step Guide
Step 1: Upload File in WordPress
First, you need to upload the file you want to track in the WordPress backend. Navigate to the "Media" section and select "Add File". Here you can upload a PDF file (or another file format).

Once the file is uploaded, you can copy the link to the file in the media overview. You will need this link later for the download tracking process.

Step 2: Access Google Tag Manager and Create Variable
Now go to your Google Tag Manager. Here we will create a new custom variable that we will use for tracking later. Click on "Variables" and then "New". Name the variable "return filename".

To configure the variable, select "Custom JavaScript Variable". A small code is necessary here, which you can simply copy and paste.

Make sure there are no spaces left at the end, as this could affect functionality.
Step 3: Create Click Triggers
Once the variable is set up, you need to create a trigger. This trigger will be responsible for triggering the download tracking. Go to "Triggers" and click "New". Name the trigger "Link Clicks PDF".

Configure the trigger to only be activated for link clicks. Set the condition that the trigger is fired when the click URL contains the text ".pdf".

This means that only clickable links leading to PDF files will be tracked.
Step 4: Create Tag for Download Tracking
Now that the trigger is ready, create a new tag in Google Tag Manager. Choose "Tag" and then "New". Set the tag type to "Universal Analytics - Event".

Fill in the fields as follows:
- Category: PDF Download
- Action: PDF
- Label: use the variable "return filename".

Step 5: Add Google Analytics ID
Link the tag with your Google Analytics Tracking-ID. If you haven't added the ID yet, you can create a new variable and insert the ID there.

Step 6: Save and Test Everything
Once everything is configured, click on "Save". You should now be able to test the tag in preview mode. Go to your website and simulate a download to check if the tag fires correctly.

Open the Tag Assistant tool and check if the download tracking is working. Make sure to keep the link to the download while clicking on it to ensure the page does not refresh.

Step 7: Checking the Results in Google Analytics
Once the download has been tested, you can check in Google Analytics to see if the data is being correctly captured. Go to the "Events" section under "Reports" and look for the downloads you have tracked.

Here you should be able to see the downloads of the PDF files. If you want to track multiple file types, repeat the steps and adjust the trigger conditions accordingly.
Summary
In this guide, you have learned how to set up effective download tracking for PDF files with Google Analytics. You have gone through each step from file upload in WordPress to configuring the Google Tag Manager and verifying the analytics data.
Frequently Asked Questions
How do I add download tracking for other file types?You can add common file extensions like.zip,.doc, and.xls to the trigger settings and adjust them accordingly.
What should I do if my tag is not firing?Check the trigger conditions and make sure the URL is configured correctly.
Will the tracking also work for internal links?Yes, the tracking works for all links as long as the conditions in your trigger are met.