Track Image and Document Downloads in Google Tag Manager

Tracking images and document downloads in Google Tag Manager can be completed in just a few steps. Google Tag Manager has a host of built in variables that will give you the ability to capture a whole host of data. However, for this exercise, we will create our own so that we can pull that data in Google Analytics. So here is are the 3 parts we will follow:

1. Create a Custom Variable to capture the data
2. Create a Trigger to fire when images and documents are downloaded
3. Create a Tag to track the downloads in Google Tag Manager.

Create a Variable

1. Open Google Tag Manager and choose variables
2. Create a Custom Variable by clicking New under User Defined Variable
3. Name this Variable “Click Download Files”
4. Choose Element URL for the variable type
5. Choose Path for the component type
5. For default pages, you can just add your domain URL

Capture Downloads and Images with GTM

Create a Trigger

1. Click Triggers and Name the Trigger. Download Trigger or whatever naming convention you prefer.
2. Under Trigger Configuration, choose Link Clicks — Just Links
3. For your firing conditions, you are going to choose your new variable and regex matching the file type you want to track
For example here is a catch all solution that may help.
\.(pdf|xlsx|png|docx)$

Trigger for GTM download tracking

Create a Tag

1. Use the Google analytics Tag(universal)
2. Put in your GA ID for Tracking ID
3. Track Type, choose Event
4. For Categoy, Event
5 For Event Action place your new Download variable
6. For Label you can choose Page URL