I was happy to find out that Google Analytics 4 can track file downloads. However, I didn’t find any native report in the interface to display the downloaded file names, other than for the last thirty minutes. It actually requires jumping through a lot of hoops to set up a report to do this. After searching online, I found a great video from Growth Learner which explains this and many other things.
In this post, I’ll try to summarize the steps to generate a report in Google Analytics 4 showing the filenames of the files that have been downloaded on your site. No Google Tag Manager required.
1. Make Sure Tracking of File Downloads is Enabled
The first thing you should do is verify that Enhanced Measurement is enabled for File Downloads. This is enabled by default, so you’re probably fine, but if you want to verify, log into your GA4 account, here’s how:
Click Admin (gear icon in lower left corner) -> Setup Assistant -> Data Streams -> Click your site name
Once there, click “+ 3 more” in the Enhanced Measurement section to show all of the items you’re measuring. Make sure “File downloads” is one of them.
If not, add it by clicking the gear icon.
2. Create an Exploration
The next thing you want to do is create an “Exploration”, which is just kind of a fancy name for a custom chart.
In the left sidebar menu of Google Analytics 4, click on Explore, then click the plus sign to create a blank Exploration.
In the top left, change the Exploration Name to something that makes sense, such as “Downloads”.
3. Add Variables to the Exploration
In the left Variables column, there are areas for Dimensions and Metrics. You’ll want File name as one of your dimensions and Event count as one of your metrics. Click the plus sign to add these.
4. Drag to Tab Settings
Once you’ve added the proper variables in the Variables column, they become available to drag to the Tab Settings column.
Click the bar graph icon near the top, then drag “File name” to BREAKDOWNS and “Event count” to VALUES as shown:
Even though you will see data, you’re not done yet…
5. Set Filters
You need to filter the result so that only file downloads show up in the graph. Go to the FILTERS section. Drag or select Event name, then set it to “exactly matches” “file_download” as shown:
Once you’ve done that, you should see a nice graph to the right with downloaded filenames as the y-axis and the number of downloads as the x-axis!
If you have long filenames, it might be kind of hard to read, but you can export the results to a spreadsheet.
6. Set Date Range
Near the top of the left Variables column, you can set the date range for the graph.
7. Set Data Retention Time
The time frame for the graph is set in the pulldown in the Variables column. Reader Tony noticed that in his account, he could only select the last 60 days of data though. I had the same problem with my account too!
The solution, he found, is to set your “data retention” to 14 months (the max) instead of 2 months (the default). To do this, go to your GA4 account -> Admin (gear icon in the lower-left corner) -> Data Settings -> Data Retention, and set that to 14 months as shown:
The 14-month data storage limitation is ludicrous in my opinion. Hopefully, Google will extend that in the future.
Another limit that reader David discovered is a 100-character limit on the path plus filename. Even if you export the data, the path/filenames will be cropped at 100 characters. I don’t know of a way around this either, as the limit seems to be baked into Google’s database.
You can see more of the filenames by hovering over them with the mouse, but they’re still limited to 100 characters.
Hope this helps! Did it work for you? Please leave a comment below. – Brian