How to Measure File Downloads in Google Data Studio

How to Measure File Downloads in Google Data Studio

In this post I’ll show a method to measure file downloads in Google Data Studio. To be more accurate, I’ll show how to track file downloads in Google Tag Manager and how to monitor and measure the types of file that have been downloaded in Google Data Studio.

Below are examples of files you can download. Click on any of them if you like.

Below is a Data Studio report that shows the number of downloads for each file type. I’ll go through the steps needed to track these downloads in Tag Manager as well as display them in Data Studio.

How to track File Downloads using Google Tag Manager

I based this method of tracking file downloads on this video from Metric Mogul and taking a look at blog posts from Simo Ahava.

Start off to creating a new tag.

Google Tag Manager (GTM) click to create new tag

You’ll then need to click on Tag configuration.

Click to configure a new tag.

And choose the Google Analytics – Universal Analytics tag type.

Choose the Google Analytics tag type in Google Tag Manager GTM

I’ve set up the tag in the following way;

Track Type = Event
Category = Downloads
Action = Downloaded File
Label = {{Click URL}}

And choose your Google Analytics tracking ID variable.

The next step is to create the Trigger to go with this tag.

Create a Trigger in Google Tag Manager

Click to configure the trigger and then choose Click > Just Links.

Use the following setup for the trigger;

Click URL
matches Regex
\.(pdf|xlsx|xls|doc|txt|png|docx|ppt|pptx)$

The Trigger showing the Regex to track file downloads in Google Tag Manager

You can add in any other document file extensions that you may need to track.

We now have our Tag which I will name GA – Downloaded File.

Making sure the tag is working using Google Tag Manager

Once we’ve created our tag and trigger, the next step is to make sure it’s firing correctly. To do this we can first check using GTM’s preview mode. Click on Preview and then go to a page with a downloadable file on it.

Click to download a file and you should see your tag fire, as shown below.

GTM preview Tags fired on this page GA downloaded file

Making sure the tag is working using Google Analytics

Another way to make sure that the correct information is being sent to Google Analytics. Open GA and navigate to Real-time > Events.

Google Analytics - Real-time - Events

You can then downloaded the file from your website a few more times. If it’s set up correctly you should see your files appearing under Events.

Google Analytics real-time events showing file downloads.

Now that we’ve confirmed the file downloads are being tracked properly, we can set up a report to monitor the downloads in Google Data Studio.

Building a report to track File Downloads in Google Data Studio

Choose Google Analytics as your data source and add it to your report.

Select Google Analytics as a Data Source

Click on Add a Field and then use the following CASE statement. This will create a new Dimension based on file type.

CASE 
WHEN REGEXP_MATCH(Event Label, ".*pdf") THEN "PDF"
WHEN REGEXP_MATCH(Event Label, ".*xls") THEN "Excel"
WHEN REGEXP_MATCH(Event Label, ".*xlsx") THEN "Excel"
WHEN REGEXP_MATCH(Event Label, ".*doc") THEN "Word"
WHEN REGEXP_MATCH(Event Label, ".*docx") THEN "Word"
WHEN REGEXP_MATCH(Event Label, ".*txt") THEN "Notepad text"
WHEN REGEXP_MATCH(Event Label, ".*png") THEN "png"
WHEN REGEXP_MATCH(Event Label, ".*ppt") THEN "Powerpoint"
WHEN REGEXP_MATCH(Event Label, ".*pptx") THEN "Powerpoint"
ELSE "Other"
END

Here’s what it should look like once you’ve added the statement.

Downloaded File Type CASE statement screenshot. Allows you to measure file downloads in Google Data Studio

We can then create a table with the newly created Downloaded File Type as our dimension and Total Events as our metric.

Depending on how many files you have downloaded, it should look something like this.

file downloads in Google Data Studio

To get a breakdown of exactly which file was downloaded we created another table, but this time we choose Downloaded File Type and Event Label as our dimensions and Total Events is still our metric.

file downloads in Google Data Studio

We then have a complete breakdown of which files were downloaded. You can choose to ‘apply filter’ to the first table, so we can filter the table below by file type.

data for file downloads in Google Data Studio

Finally, in order to only show file downloads in these tables (and not other events) we create a filter for the tables that only includes the Downloads Event Category.

filter for file downloads in Google Data Studio

Hope you found this article about how to measure file downloads in Google Data Studio useful.

If you liked this article you might like my other blog posts.

Or you can follow me on Twitter!

Michael

Author Michael

More posts by Michael

Join the discussion 2 Comments

  • Julian says:

    Sorry, but I find the post title is a bit misleading. Data Studio is not a Tracking tool, it can’t track File Downloads. You need Google Analytics for this, which then is used as a data source in Data Studio. The headline had me really confused. Just my 2Cents

    • Michael says:

      Hi Julian, thanks for the feedback. Actually think you’re 100% correct about this so I’ve changed the post text from track to measure.

Leave a Reply