Track Downloads Automatically with Google Analytics and Tag Manager 12

Through this post I’m explaining how to simply measure automatically documents downloaded on your website.

To do this, you must have Google Tag Manager, as we are going to use the feature named as auto event tracking.

 1. Create the tag to configure the listener

The first thing we need to do is to create a new tag in the Google Tag Manager console. If you have not created that tag it in the past, you need to include the tag named as Link Click Listener, which can be found under the Event Listener category.

The screenshot displayed below is showing how to configure it:

download-documents-listener

This tag will be listening for any click on a link of your website, as the tag is executed on every page (see the rule). When this happens, it will fire a Google Tag Manger event “gtm.linkClick”, which we are going to use when creating the rule.

 2. Create the rule

The next step is creating the rule that will fire the tag to send the information to Google Analytics upon clicking on a document of our site.

The rule will be using a default macro that Google Tag Manager has, and this is named as {Element URL}. This macro will contain the URL of the button clicked when the previous tag fires the event gtm.linkClick. Hence the rule has to have two conditions:

  1. Click on a link – event matches “gtm.linkclick”
  2. The link is a document – {Element URL} contains “(\.doc|\.docx|\.pdf|\.ppt|\.pptx|\.xls|\.xlsx|\.xml|\.txt|\.csv)$”

As you can see in the following screenshot, both conditions are included within the rule.

download-documents-rule

 3. Create the tag to send the information

The last step is utilise the rule to send the information about the click to Google Analytics. When the conditions happen, we are using a Google Analytics event to send the information.

You can utilise the next screenshot as an example, or configure it with your own values.

download-documents-tagdownload-documents-listener

 

Remember to include the rule we’ve just created, save the tag and publish a new version of the container!

Easy right? Please reply to the post if you find an issue or you need any help!

12 thoughts on “Track Downloads Automatically with Google Analytics and Tag Manager

  1. Comentar Josh jul 13, 2014 15:17

    This method does not track when a user right-clicks and opens the file in a new window or right-clicks then saves the file.

  2. Comentar yoss oct 6, 2014 12:41

    Thanks for this tutorial :)

    But where can we see the results of the downloads tracking ? Is it on Google Analytics or GTM ?

  3. Comentar shreekant oct 29, 2014 22:56

    Hi,

    To tracking the pdf download, what is the exact code which I will use in website.I am using GA-universal with GTM.

    waiting for reply,
    Thanks,
    Shreekant

  4. Comentar Elías Nuevo oct 30, 2014 09:43

    Hi Shreekant,

    The only code you’ll need in your website is the GTM snippet of code. Everything else is done from the GTM interface! :)

    I hope it makes sense!

    Thanks,
    Elias

  5. Comentar Chris mar 31, 2015 23:48

    Hi,

    Thank you for taking the time to write this article up. The document download tracking has been configured on Google Tag Manager. We deployed the container to a test environment. We previewed GTM and clicked on the test domain. Shouldn’t we be able to confirm if the document download tracking is working via Real-Time Event on Google Analytics?

    Thanks,
    Chris

    • Comentar Elías Nuevo abr 3, 2015 09:55

      Hi Chris,

      Thanks for your message.

      Yes, the event should be coming in real time, if your session is not filtered out via IP. I’d also recommend using a browser ad-on to check if the data is sent. HTTPFox or Firebug for Firefox, or alternatively Google Chrome Developers Console.

      I hope this helps!

      Thanks,
      Elias

  6. Comentar Jessica abr 6, 2015 20:29

    Hi I am a newbie.

    I am tracking links on my homepage. However the url is the same for multiple links on the page in the Navigation, and homepage body. I want exclude the links in the navigation. How may I do this?

    • Comentar Elías Nuevo may 16, 2015 10:25

      Hi Jessica,

      I’d suggest using exclusion rules to avoid them firing when you don’t want to. Within the rules you can use the auto event variables, Element Class, Element ID, etc.

      Thanks,
      Elias

  7. Comentar Meghan Lundy may 15, 2015 23:49

    I am unable to get this to work. Its all setup the pages I am clicking on are tracking but the documents are not.

    Any ideas??

Publicar un comentario a Elías Nuevo Cancelar la publicación