Subscribe to our social networks

arrow icon All Post

How to use Google Tag Manager to Track Traffic from PDF File Links

Feb 21, 2024 | Author: Info Publytics

How to use Google Tag Manager to Track Traffic from PDF File Links

Here's a guide on how to track traffic from PDF file links using Google Tag Manager or URL parameters

PDF files are a common way to share valuable content with your audience, such as ebooks, white papers, reports, guides, etc. However, if you want to measure the impact of your PDF files on your website performance, you need to track the traffic that comes from the links to your PDF files. In this blog post, I will show you how to do that using Google Analytics and Google Tag Manager.

Why Track Traffic from PDF File Links?

Tracking traffic from PDF file links can help you answer questions like:

  • _How many people are downloading your PDF files?
  • _How long are they spending on your PDF files?
  • _Which PDF files are the most popular and engaging?
  • _Which sources are driving the most traffic to your PDF files?
  • _How are your PDF files contributing to your conversions and goals?

By answering these questions, you can optimize your PDF files for better user experience, content quality, and marketing effectiveness. You can also identify the best practices and strategies for creating and promoting your PDF files.

How to Track Traffic from PDF File Links with Google Analytics

Google Analytics is a powerful tool that can help you track and analyze your website traffic. However, by default, Google Analytics does not track PDF file downloads as page views or events. This means that you will not see any data about your PDF file traffic in your Google Analytics reports.

To solve this problem, you need to use a custom solution that can send data about your PDF file downloads to Google Analytics. There are two main ways to do this:

  • 1) Using Google Tag Manager
  • 2) Using URL parameters

1) Using Google Tag Manager

Google Tag Manager is a tool that allows you to manage and deploy tags (such as Google Analytics) on your website without modifying the code. Using Google Tag Manager, you can create a tag that will fire whenever a user clicks on a link to a PDF file on your website, and send an event to Google Analytics with the information about the PDF file.

Here are the steps that you need to follow to track PDF file downloads with Google Tag Manager and Google Analytics:

  1. 1.1 Create a link click trigger (for .pdf files)
  2. 1.2 Enable click-related variables
  3. 1.3 Create a Google Analytics event tag
  4. 1.4 Insert click URL variable in that tag
  5. 1.5 Set this tag to fire only when the PDF link is clicked
  6. 1.6 Check Google Analytics reports

1.1 Create a link click trigger (for .pdf files)

The first step is to create a trigger that will detect when a user clicks on a link to a PDF file on your website. To do this, go to your Google Tag Manager account and click on Triggers. Then, click on New and name your trigger something like PDF Link Click.

Next, choose the trigger type as Link Click. This will tell Google Tag Manager to listen for link clicks on your website.

Then, under This trigger fires on, select Some Link Clicks. This will allow you to specify the conditions for the trigger to fire.

Next, click on the + button to add a condition. Choose Click URL as the variable, ends with as the operator, and .pdf as the value. This will tell Google Tag Manager to fire the trigger only when the click URL ends with .pdf, which means it is a link to a PDF file.

Finally, click on Save to save your trigger.

1.2 Enable click-related variables

The next step is to enable some variables that will capture the information about the link click, such as the click URL, the click text, the click ID, etc. These variables will be used later in the Google Analytics tag.

To enable these variables, go to your Google Tag Manager account and click on Variables. Then, under Built-In Variables, click on Configure.

Next, scroll down to the Clicks section and check the boxes for the following variables:

  • Click URL
  • Click Text
  • Click ID
  • Click Classes
  • Click Element

These variables will store the values of the corresponding attributes of the link that was clicked.

1.3 Create a Google Analytics event tag

The next step is to create a tag that will send an event to Google Analytics with the information about the PDF file download. To do this, go to your Google Tag Manager account and click on Tags. Then, click on New and name your tag something like GA - PDF Download.

Next, choose the tag type as Google Analytics: Universal Analytics. This will tell Google Tag Manager to use the Universal Analytics version of Google Analytics.

Then, under Track Type, select Event. This will tell Google Analytics to track the PDF file download as an event.

Next, under Event Tracking Parameters, enter the following values:

  • Category: PDF Download
  • Action: {{Click URL}}
  • Label: {{Click Text}}

These values will define the event category, action, and label that will be sent to Google Analytics. The category is a general name for the type of event, the action is a specific name for the action that triggered the event, and the label is an optional value that can provide additional information about the event.

In this case, we are using the click URL variable as the action, which will store the URL of the PDF file that was downloaded. We are also using the click text variable as the label, which will store the text of the link that was clicked.

You can also optionally enter a value for the Non-Interaction Hit parameter. This parameter tells Google Analytics whether the event should affect the bounce rate calculation or not. If you set it to True, the event will not affect the bounce rate. If you set it to False or leave it blank, the event will affect the bounce rate.

Next, under Google Analytics Settings, select your Google Analytics variable or enter your Google Analytics tracking ID. This will tell Google Tag Manager which Google Analytics property to send the event data to.

Finally, under Triggering, select the trigger that you created earlier, PDF Link Click. This will tell Google Tag Manager to fire the tag only when the PDF link click trigger is fired.

Click on Save to save your tag.

1.4 Insert click URL variable in that tag

The next step is to insert the click URL variable in the Google Analytics event tag. This will allow you to see the URL of the PDF file that was downloaded in your Google Analytics reports.

To do this, go to your Google Tag Manager account and click on Tags. Then, click on the tag that you created earlier, GA - PDF Download.

Next, under Event Tracking Parameters, click on the + button next to Fields to Set. This will allow you to add custom fields to the Google Analytics tag.

Then, enter the following values:

  • Field Name: document.location
  • Value: {{Click URL}}

These values will tell Google Analytics to use the click URL variable as the document location for the event. The document location is the URL of the page where the event occurred.

Click on Save to save your tag.

1.5 Set this tag to fire only when the PDF link is clicked

The next step is to set the Google Analytics event tag to fire only when the PDF link is clicked. This will prevent the tag from firing on other link clicks that are not related to PDF files.

To do this, go to your Google Tag Manager account and click on Tags. Then, click on the tag that you created earlier, GA - PDF Download.

Next, under Triggering, click on the trigger that you selected earlier, PDF Link Click.

Then, under This trigger fires on, make sure that the condition is set to Click URL ends with .pdf. This will tell Google Tag Manager to fire the trigger only when the click URL ends with .pdf, which means it is a link to a PDF file.

Click on Save to save your tag.

1.6 Check Google Analytics reports

The final step is to check your Google Analytics reports to see the data about your PDF file downloads. To do this, go to your Google Analytics account and navigate to Behavior > Events > Top Events.

Here, you will see a report that shows the events that occurred on your website, grouped by category, action, and label. You can click on the PDF Downloadcategory to see the details of the PDF file downloads.

You will see the following information:

  • Event Action: The URL of the PDF file that was downloaded
  • Event Label: The text of the link that was clicked
  • Total Events: The number of times the PDF file was downloaded
  • Unique Events: The number of unique users who downloaded the PDF file
  • Event Value: The value assigned to the event (if any)
  • Avg. Value: The average value of the event (if any)
  • Event Rate: The percentage of sessions that included the event

You can also use the Secondary Dimension feature to add more dimensions to the report, such as source, medium, campaign, etc. This will allow you to see the sources and channels that drove the most traffic to your PDF files.

You can also use the Advanced Segments feature to segment your data by different criteria, such as device, location, behavior, etc. This will allow you to see the characteristics and preferences of your PDF file downloaders.

2) Using URL Parameters

 URL parameters are extra pieces of information that you can add to the end of a URL to pass some data to the server or the browser. By using URL parameters, you can tell Google Analytics, or any web analytics tool where the traffic is coming from and how it behaves on your site.

For example, if you have a PDF file called brochure.pdf on your website, you can add a parameter like this: 

brochure.pdf?utm_source=facebook&utm_medium=social&utm_campaign=summer_sale

This parameter tells Google Analytics that the traffic is coming from Facebook, through a social channel, and as part of a summer sale campaign. You can customize these values according to your needs.

To generate these parameters, you can use Publytics’s URL builder, which is a tool that helps you create and append parameters to your URLs. You just need to enter your website URL, the source, the medium, the campaign, and any other optional parameters you want to track.

Once you have your URL with parameters, you can use it to link to your PDF files from your website, social media, email, or any other source. Then, you can check your Google Analytics reports to see the data about your PDF file traffic.


Posted: 5 months ago
Author: Info Publytics

Recent Posts

bg img

    Are you looking for a complete tool to measure your website's progresses? Get deep into Publytics with our 14 Days of free trial!

  • Try it for free