// Tutorial //
Knowledge Base

Tracking PDF link clicks as conversions in Google Ads

Last updated: September 20, 2024
Featured Image

Tracking user interactions like PDF link clicks is essential for understanding engagement and optimizing marketing efforts. However, when users click on a link that immediately navigates away from your site (such as downloading a PDF), tracking can fail because the necessary tags don’t have time to fire.

This tutorial will walk you through setting up conversion tracking for a PDF link clicks on your website using Google Tag Manager (GTM) and Google Ads. We’ll create a custom HTML tag to delay navigation, ensuring the conversion tracking tag fires before the user is redirected to the PDF.

Prerequisites

  • Google Tag Manager Account: Set up and installed on your website.
  • Google Ads Account: With administrative access.
  • Basic Knowledge: Familiarity with GTM and Google Ads is helpful but not required.

Steps Overview

  1. Create a Conversion Action in Google Ads
  2. Set Up a Conversion Tracking Tag in GTM
  3. Implement a Custom HTML Tag to Delay Navigation
  4. Test and Publish Your Tags

Step 1: Create a Conversion Action in Google Ads

1.1 Navigate to Conversions

  • Log in to Google Ads.
  • Click the “Goals” icon (trophy or flag) on the left menu.
  • Select “Conversions”.

1.2 Create a New Conversion Action

  • Click “+ New conversion action”.
  • Select “Website” and click “Next”.

1.3 Set Up Conversion Details

  • Domain: Enter your website URL and click “Scan” or “Add a conversion action manually”.
  • Conversion Name: e.g., “PDF Download Click”.
  • Category: Choose “Download” or “Other”.
  • Value: Select “Don’t use a value”.
  • Count: Choose “One” to count only one conversion per user per session.
  • Click-through Conversion Window: Leave at default (30 days) or adjust as needed.
  • Attribution Model: Select “Last click”.

1.4 Save and Get Tag Details

  • Click “Done” or “Save and continue”.
  • Under “Tag setup”, choose “Use Google Tag Manager”.
  • Copy the Conversion ID and Conversion Label.

Step 2: Set Up a Conversion Tracking Tag in GTM

2.1 Create the Conversion Tag

  • In GTM, go to Tags > New.
  • Name it “Google Ads Conversion – PDF Click”.
  • Tag Type: Select “Google Ads Conversion Tracking”.
  • Conversion ID and Conversion Label: Paste the values from Google Ads.

2.2 Create a Click Trigger

  • Go to Triggers > New.
  • Name it “PDF Link Click”.
  • Trigger Type: Choose “Just Links” under “Click”.
  • This trigger fires on: Some Link Clicks.
  • Condition:
    • Click URL contains your-pdf-file.pdf.
    Replace your-pdf-file.pdf with your actual PDF file name or unique part of the URL.
  • Save the trigger.

2.3 Assign Trigger to the Tag

  • In your “Google Ads Conversion – PDF Click” tag, add the “PDF Link Click” trigger.
  • Save the tag.

Step 3: Implement a Custom HTML Tag to Delay Navigation

3.1 Create the Custom HTML Tag

  • In GTM, go to Tags > New.
  • Name it “Delay PDF Link Navigation”.
  • Tag Type: Select “Custom HTML”.

3.2 Add the Code

<script>
  document.querySelectorAll('a[href$="your-pdf-file.pdf"]').forEach(function(link) {
    link.addEventListener('click', function(event) {
      event.preventDefault();
      setTimeout(function() {
        window.location.href = link.href;
      }, 1000); // Adjust the delay as needed (1000ms = 1 second)
    });
  });
</script>
  • Note: Replace 'your-pdf-file.pdf' with your actual PDF file name or a unique part of the URL.

3.3 Explanation of the Code

  • document.querySelectorAll: Selects all anchor (<a>) tags ending with your PDF filename.
  • addEventListener: Adds a click event listener to each link.
  • event.preventDefault(): Prevents the default action (immediate navigation).
  • setTimeout: Delays the navigation to the PDF by the specified time (e.g., 1000 milliseconds).
  • window.location.href: Redirects the browser to the PDF URL after the delay.

3.3 Set the Trigger

  • Under “Triggering”, select “All Pages”.
  • Save the tag.

Step 4: Test and Publish Your Tags

4.1 Preview and Test

  • Click “Preview” in GTM to enter Debug mode.
  • On your website, click the PDF link.
  • Ensure that:
    • The “Delay PDF Link Navigation” tag fires on Page View.
    • The “Google Ads Conversion – PDF Click” tag fires on Link Click.

4.2 Publish Your Tags

  • Exit Preview mode.
  • Click “Submit” in GTM.
  • Add a version name (optional) and click “Publish”.

Verification in Google Ads

  • Wait up to 24-48 hours for conversions to appear.
  • In Google Ads, go to “Goals” > “Conversions”.
  • Check that your “PDF Download Click” conversion action is recording conversions.

Check the Network Request on your browser for debugging

Use GTM’s Preview and Debug mode to simulate the click and verify that the tag fires and the data is sent to Google Ads. Then, Check the Network tab in your browser’s developer tools to see if the conversion tracking request (https://www.googleadservices.com/pagead/conversion/) is sent. For doing so, follow these steps:

  1. Open Developer Tools:
    • Press F12 or right-click and select “Inspect”.
    • Go to the Network Tab:
  2. Filter by googleadservices.com or ads.
  3. Click the PDF Link Again:
  4. Confirm that a request is sent to https://www.googleadservices.com/pagead/conversion/ with your Conversion ID and Label.
  5. Ensure the request status is 200 OK.

Notes

  • Adjust the Delay: Modify the 1000 milliseconds (1 second) in the custom HTML code if needed. You can shorten the delay (e.g., to 300 milliseconds) if 1 second feels too long. Ensure the delay is sufficient for the conversion tag to fire.
  • Testing: Disable ad blockers during testing, as they may interfere with tracking.
  • Multiple PDFs: For multiple PDFs, adjust the selector in the code or create additional tags.

Conclusion

By following these steps, you’ve set up conversion tracking for PDF link clicks on your website using Google Tag Manager and Google Ads. The custom HTML tag delays navigation to the PDF, allowing the conversion tag to fire successfully.

Table of content

Related Content
Grow your
business with us
Start marketing with Marketing Done Right and together let’s build your brand.
We are a group of professional marketers, website builders, and developers with the goal of delivering high-quality services to our clients.
© 2024
Marketing Done Right, LLC. all rights reserved.