Blog

+ Free advice and other musings

How to Track File Downloads using Google Tag Manager v2

by | Oct 7, 2015 | Google Analytics

How to Track File Downloads using Google Tag Manager v2
One Tag, One Trigger, One Variable: Learn how to track file downloads using Universal Analytics and GTM v2.

Learn how to track file downloads using Google Tag Manager v2 and Universal Analytics.

Both Google Analytics and Google Tag Manager have received facelifts over the last couple of years. The changes are good, but as a non-programmer some of the setup for Google Tag Manager v2 might be a little foreign. Here's how I recommend getting started with tag manager. I'm going to assume you are using Universal Analytics and that you have set up a Google Tag Manger account. Note: These are instructions for Google Tag Manager version 2, effective May 2015

The Basics of Collecting Data

  1. Make sure the Google Tag Manager snippet is in the correct spot on your webpages. It should appear after the opening <body> tag. See the Google setup instructions.
     
  2. Create your first variable. Instructions below for creating user-defined variables and using auto-event variables.
     
  3. Create your triggers and tags. The below post includes How-to Instructions for Event Tracking for File Downloads.

In order to send data to Google Analytics, you need an event tag. This is a tag that reports to Analytics actions like a visitor downloading a PDF, signing up for a newsletter or clicking a social media or article link that takes them off your website.

An Event Tag needs a Trigger and a trigger needs a Variable.

  • A variable is some defined piece of information.
  • A trigger determines if the conditions of the variable are met.
  • A tag fires, or sends the data to Analytics or another third party, when triggered.


How-To Create a User-Defined Variable (and why you want to)

The first variable to create is a reusable Google Analytics property variable.

Event Tags that send data to your Google Analytics account need to know your Google Analytics tracking ID. It's a string like this UA-XXXXXX-XX. Instead of constantly looking up the tracking ID for your tags, I recommend creating a user-defined variable that you can insert instead.

If you do website design, think of this like CSS or an include file.
If you're a pen and paper person, think if this like stationery. No need to draw the company logo each time.

Follow the instructions here to create a user-defined variable for your Google Analytics tracking ID:
https://support.google.com/analytics/answer/6224398?hl=en


How-To Instructions for Creating Event Tracking Triggers and Tags

Now that you have the reusable gaProperty variable created, it's time to set up triggers and tags.

How to Track Downloads of PDFs, ePUBs, and Other Files using GTM v2

Steps:
1. Create an Auto-Event Variable that captures the clicked link
2. Create an Event Trigger that uses the Link Click trigger type to check if the link includes extensions you want to track like .pdf, .epub, etc.
3. Create the Event Tag to fire when the downloadable file link is click and send that data to Google Analytics > Behaviour > Events.

In Step 1 we are creating an auto-event variable that captures the clicked link. We are creating a variable so that when we create the trigger in Step 2, we are able to say “fire when the Click URL Path matches the specified extensions”. The event tag is the final step that sends the info to Google Analytics.

Instructions:
Follow Simo Ahava's excellent instructions on Step 1 and 2, setting up the auto-event variable and event trigger to track file downloads
http://www.simoahava.com/gtm-tips/track-file-downloads-in-gtm-v2/

Then for Step 3, create the event tag as follows:

Create a new Universal Analytics tag

  1. Give it a name (such as gaEvent Send Download)
  2. Select Google Analytics
  3. Select Universal Analytics (assuming you are not using Classic)
  4. Add your tracking ID (it’s best to store it as a macro, see above for creating a user-defined variable for gaProperty)
  5. Choose Event as the Track Type
  6. Add your event parameters, including Event Category (such as Downloads)
  7. Choose Click URL as Event Action
  8. Choose Page URL as Event Label
  9. Set the event to fire on Click
  10. Specifically fire the tag on clicks that match the Trigger, or conditions you set, for file downloads
  11. Save tag

 

Have questions? Ask in the comments. Or simply hire Boxcar Marketing to set up Event Tracking using GTM v2.

You may also like …

How to Track Marketing Campaigns in GA4

How to Track Marketing Campaigns in GA4

Holiday campaign tracking provides insights into what's working or not working. But you need to set it up. It's 5 weeks and 3 days until Black Friday, and even if your business is not located in America, this retail event kicks off the holiday shopping season around...

read more