How do I track downloads (like PDFs or ZIP files) in GA4?

Applies to: Google Analytics 4 (GA4)
Last updated: May 2025


Problem

You want to know when users download files (such as PDFs, ZIPs, DOCXs) from your website. GA4 does not automatically track all file downloads unless Enhanced Measurement is properly configured or custom tagging is used.


Solution

GA4’s Enhanced Measurement feature tracks file downloads automatically for common file types. For more control or unsupported file types, use Google Tag Manager (GTM) to track them as custom events.


Option 1: Use Enhanced Measurement (Automatic)

GA4 automatically tracks downloads when:

  • The file link is a direct anchor tag (<a href="file.pdf">)
  • The file has a recognized extension (e.g., .pdf, .docx, .xls, .zip, etc.)

Steps:

  1. Go to https://analytics.google.com
  2. Admin > Data Streams > Select your Web Stream
  3. Under Enhanced Measurement, click the gear icon
  4. Ensure File Downloads is toggled on

This creates file_download events automatically with parameters like:

  • file_name
  • file_extension
  • link_url

Option 2: Track Downloads with GTM (Custom Setup)

Use this method for greater accuracy, filtering, or for links that trigger downloads via JavaScript.

Step 1: Enable Click Variables

  • In GTM, go to Variables > Configure
  • Enable:
    • Click URL
    • Click Text
    • Click Classes

Step 2: Create a Link Click Trigger

  1. Go to Triggers > New
  2. Choose Trigger Type: Just Links
  3. Configure conditions, such as:
    • Click URL matches regex: \.(pdf|zip|docx|xlsx)$
  4. Set trigger to fire on Some Link Clicks
  5. Name and save it (e.g., “Download Trigger”)

Step 3: Create a GA4 Event Tag

  1. Go to Tags > New
  2. Choose Tag Type: GA4 Event
  3. Set:
    • Event Name: file_download
    • Event Parameters:
      • file_name: {{Click URL}}
      • link_text: {{Click Text}}
  4. Attach the download trigger you created
  5. Save and publish

Step 4: Test in Preview Mode

  • Use GTM’s Preview to click a download link
  • Confirm the event fires
  • Check GA4 DebugView for file_download events

Step 5: Register Custom Parameters (Optional)

To make file_name or link_text available in GA4 reports:

  1. Go to Admin > Custom Definitions
  2. Create a Custom Dimension
    • Scope: Event
    • Parameter: file_name or link_text
  3. Save

Viewing Downloads in GA4

  • Go to Reports > Engagement > Events
  • Click on file_download
  • Use dimensions like link_url, file_name, or custom values in Explorations

Notes

  • GA4’s Enhanced Measurement covers many file types but may miss JavaScript-based or dynamic downloads
  • Use GTM for more flexibility, such as filtering by download type or creating download-specific conversions
  • You can mark file_download as a conversion in GA4 if it’s a key action

You may also like...