Key takeaways
- GA4 Enhanced Measurement can track file downloads automatically — but only for common file types and only on the same domain
- GTM gives you full control over which file types are tracked, what parameters are captured, and how downloads are named in reports
- Always use a link click trigger with a file extension regex — not a generic all-clicks trigger
- Capture file name, file extension, and the page the download happened on as event parameters
- For gated downloads behind a form, track the form submission — not the file link click — as the conversion event
In this article
- GA4 Enhanced Measurement — the quick option
- Why Enhanced Measurement is often not enough
- Tracking downloads with GTM — full control
- Building the click trigger
- Capturing file name and extension
- Creating the GA4 event tag
- Cross-domain and hosted file downloads
- Tracking file downloads in Adobe Analytics
- Reporting on downloads in GA4
- Common mistakes
File downloads are one of those tracking requirements that sounds simple until you actually implement it. The data you get from a poorly configured download tracker — or from just relying on GA4's Enhanced Measurement — often tells you less than you think, and sometimes actively misleads you.
This guide covers how to track file downloads correctly across GA4 and GTM, what parameters to capture, and how to avoid the mistakes that make download data unreliable.
GA4 Enhanced Measurement — the quick option
GA4 includes file download tracking as part of Enhanced Measurement. When enabled, GA4 automatically fires a file_download event when a user clicks a link that ends in a recognised file extension.
To enable it: GA4 → Admin → Data Streams → your web stream → Enhanced Measurement → toggle on File Downloads.
GA4 automatically tracks these extensions out of the box:
pdf, xlsx, docx, txt, rtf, csv, exe, key, pps, ppt, pptx, zip, rar, 7z, tar, gz, mp3, mp4, mov, avi, wmv, mkv
The event parameters captured automatically are:
- file_name — the full file name with extension
- file_extension — just the extension (pdf, zip, etc.)
- link_text — the anchor text of the download link
- link_url — the full URL of the file
Why Enhanced Measurement is often not enough
Enhanced Measurement works well for simple cases. It breaks down when you need:
- Custom file type support — if your downloads use non-standard extensions or are served through a redirect URL that does not end in a file extension, Enhanced Measurement will not detect them
- Custom parameters — you cannot add your own parameters (document category, user tier, campaign source) without GTM
- Cross-domain downloads — files hosted on a CDN or a different subdomain are not tracked by Enhanced Measurement
- Selective tracking — Enhanced Measurement is all-or-nothing for each file type. You cannot track PDFs in one section but not another without GTM
- Download as a conversion — marking a specific file download as a conversion requires the event to be configured in GTM with clear naming
Turn off Enhanced Measurement file downloads if you are implementing GTM-based tracking. Running both simultaneously results in duplicate file_download events — one from Enhanced Measurement and one from GTM — which inflates your download counts.
Tracking downloads with GTM — full control
The GTM approach gives you complete control. Here is the setup required:
Enable Click URL built-in variable
In GTM, go to Variables → Built-In Variables → Configure. Enable Click URL, Click Element, and Click Text. These are needed for your trigger conditions and data element values.
Create a file extension variable
Create a Custom JavaScript variable that extracts the file extension from the clicked URL. This gives you a clean extension value to use in your GA4 event parameters.
Create the click trigger
Create a Click — Just Links trigger that fires only when the clicked URL matches a file extension regex pattern. This is more reliable than an All Clicks trigger.
Create the GA4 event tag
Create a GA4 Event tag with event name file_download and attach your custom parameters. Link it to the click trigger from step 3.
Building the click trigger
The trigger should fire only when the user clicks a link pointing to a file. Use a regex pattern on Click URL to match the file extensions you care about:
Trigger type: Click — Just Links
Wait for tags: ✓ (check this — important for outbound files)
Check validation: ✓
This trigger fires on: Some Link Clicks
Condition:
Click URL | matches RegEx | \.(pdf|zip|xlsx|docx|csv|ppt|pptx|rar|mp4|mp3)$
// The $ anchors to end of URL so it only matches
// the extension at the end, not in the middle of a path
Always check "Wait for tags" on the click trigger. Without this, GTM may not finish sending the GA4 event before the browser navigates away to download the file. This is especially important for direct file links that trigger a browser download immediately.
Capturing file name and extension
Create two Custom JavaScript variables to extract clean values from the clicked URL:
function() { var url = {{Click URL}}; if (!url) return ''; // Get everything after the last slash var parts = url.split('/'); var filename = parts[parts.length - 1]; // Remove query strings if present return filename.split('?')[0]; }
function() { var url = {{Click URL}}; if (!url) return ''; // Extract extension from URL var match = url.match(/\.([a-zA-Z0-9]+)(\?|#|$)/); return match ? match[1].toLowerCase() : ''; }
Creating the GA4 event tag
Tag type: Google Analytics: GA4 Event
Measurement ID: G-XXXXXXXXXX
Event Name: file_download
Event Parameters:
file_name → {{JS - File Name}}
file_extension → {{JS - File Extension}}
link_url → {{Click URL}}
link_text → {{Click Text}}
page_location → {{Page URL}}
page_title → {{Page Title}}
Triggering: [your download click trigger]
The page_location and page_title parameters are important — they tell you where on your site the download happened, which is often as important as knowing which file was downloaded.
Cross-domain and CDN-hosted file downloads
If your files are hosted on a CDN subdomain (e.g. cdn.yourdomain.com/files/report.pdf) or a completely different domain, the Just Links click trigger will still fire — but the Click URL will point to the external domain. No extra configuration is needed for tracking purposes, but be aware that:
- The file will appear in GA4 with the full CDN URL in
link_url— you may want to clean this up in your GA4 reports using a custom channel grouping or Looker Studio regex filter - If the CDN URL uses a redirect before serving the file, the Click URL captured by GTM will be the redirect URL, not the final file URL — validate this by testing in GTM Preview mode
Tracking file downloads in Adobe Analytics
In Adobe Analytics via Adobe Launch, file downloads are tracked as link tracking events using s.tl(). The setup mirrors the GTM approach but uses Launch rules instead:
Rule name: Click — File Download
Event:
Type: Click
Elements matching CSS selector: a[href$=".pdf"],
a[href$=".zip"], a[href$=".xlsx"], a[href$=".docx"]
Actions:
1. Adobe Analytics — Set Variables
eVar20 = (data element reading href attribute)
eVar21 = (data element reading link text)
event10 = 1 (file download event)
2. Adobe Analytics — Send Beacon
s.tl(true, 'o', 'File Download')
In Adobe Launch, use the CSS attribute selector a[href$=".pdf"] to match links ending in specific extensions. The $= operator matches the end of the attribute value — much cleaner than a regex condition on the Click URL variable.
Reporting on downloads in GA4
Once tracking is live, your file_download events appear in GA4 under Reports → Engagement → Events. To get meaningful insight, create an Exploration report with these dimensions and metrics:
| Dimension | Metric | Insight |
|---|---|---|
| file_name | Event count | Which files are downloaded most |
| file_extension | Event count | Which file types are most popular |
| page_title | Event count | Which pages drive the most downloads |
| Session default channel group | Event count | Which traffic source drives downloads |
| file_name + Device category | Event count | Mobile vs desktop download patterns |
If specific file downloads are business-critical — a product brochure, a pricing sheet, a case study — mark those specific events as conversions in GA4 Admin → Events. You can create a separate event name for high-value downloads by duplicating the event in GA4 and filtering by file_name.
Common mistakes
- Running Enhanced Measurement and GTM download tracking simultaneously. This creates duplicate
file_downloadevents. Disable Enhanced Measurement file downloads in your GA4 data stream settings when using GTM. - Not using "Wait for tags" on the click trigger. The GA4 event never fires because the browser navigates away before GTM finishes. Always enable this option on download click triggers.
- Using an All Clicks trigger instead of Just Links. All Clicks fires on every element — buttons, images, divs. Just Links fires only on anchor tags. Use Just Links for download tracking.
- Not capturing page context. Knowing that 500 users downloaded report.pdf tells you nothing if you do not know where on the site they downloaded it from. Always include
page_locationandpage_titleas event parameters. - Tracking gated downloads by click instead of form submission. If a download is behind a form, users who fill the form but do not click the download link are missed. Track the form submission as the conversion, not the file link click.