1 июня 2018 г.

Отслеживает загрузок файлов в Google Analytics через Tag Manager

Track File Downloads in Google Analytics using 

Sometimes you want to track file downloads and show many times users download particular files like newsletters and application forms as these act as micro conversions or steps along the path to your major conversions and business goals.
In this article we will look at how to track downloads as Events in Google Universal Analytics (UA) by using Google Tag Manager (GTM) to monitor for clicks on downloads and then fire the event tag.
If you are an SEO Company looking to set this up for a client, this is particularly helpful because you can avoid having to wait for developers and get this setup fairly quickly.

Different ways to fire events

There are a number of different ways you can fire or trigger an event in Google Analytics.
  • You can hard code events into a page so they fire on a button click using a javascript onclick:
    <a href=”www.mywebsite.com/pdf/deposit-form.pdf” onclick=”ga(‘send’, ‘event’, ‘PDF’, ‘Download’, ‘Deposit Form – PDF Download’);“>Deposit Form</a>
  • Push an event using the dataLayer so it can be accessed by Google Tag Manager
    <a href=” www.mywebsite.com/pdf/deposit-form.pdf ” onclick=”dataLayer.push({‘event’: ‘deposit-form-download’});” > Deposit Form </a>
  • Use GTM’s Auto Event Tracking to listen for clicks on a link or button, and then fire the event on the button click and return the button label as the event label.

Advantages of using GTM to fire the events

  • Options 1 and 2 require a developer to edit the code on the website, which can sometimes be slow, or just not possible.
  • Using GTM, you can do all this without touching the code on the page and still get the information from the page and the action the user performed.

Setup GTM Auto Event Tracking

Let’s say we want to track file downloads of PDF files across the website. We need to:
  • Create a Trigger that listens for all clicks that leads to a file ending with “.pdf”
  • Fire our Event when someone clicks on a the button or link
  • Send the Category, Action, and Label to Analytics so they appear in reports and we can count the number of each type of download

Enable the Variables we need

In the past, you had to create Auto Event Variables to capture the information we need from the page as User Defined Variables. The new version of Google Tag Manager, GTM V2 now has these built in:
  1. We need the Text of the button the user clicks on, so we know which download has been clicked. This is called: Click Text (old User defined variable method is: element text)
  2. We also want the download URL so we only track PDF’s not all clicks
    This is called: Click URL (old User defined variable method is: element url)
We just need to tick the new inbuilt variables under the Clicks box to make them available.

GTM Variables
GTM Built in Variables


Create the Event Tag to be fired

  • Choose Product: Google Analytics
Add GTM Event Tag
Create GTM event tag
  • Select Universal Analytics
    1. Enter your UA Property ID (UA-XXXXX-XX ) or the Variable constant that you have previously setup with the property ID in it. In this case {{gaPropertyID}}.
    2. Enter the Category and Action
    3. Lastly enter the {{Click Text}} variable in the Label. This will pull in the test from the clicked button or URL

Fill out event tag
Fill out the event tag

Fire On: Create the Trigger


Create the GTM Trigger
Create the GTM Trigger

  • Select Click and new. Call it PDF Download, Configure to trigger on all elements but we want to restrict it to only PDF’s so select Some Clicks

GTM Click Trigger: click URL
GTM Click Trigger: click URL

  • You could also use the + button to add additional conditions like only restricting it to fire on your downloads page. In this case we are happy to track PDF downloads on any page.
  • If you wanted to track multiple file types, you could change this from “ends with” to “matches Regex” and use a regex to match multiple file extensions. Something like:
    \.pdf$|\.docx$
    Don’t forget to change the name of the trigger to reflect multiple file extensions though E.g. File Downloads
  • Save the trigger and your tag. Your Download Event Tracking is now setup

Viewing the results in Google Analytics

You can check everything is working correctly by viewing Real Time Events in Analytics.

Check Real Time Analytics
Check Real Time Analytics

By selecting your category, in this case Downloads & Forms, you will drill down to see the Click Text that has been pulled in to the Label of the event, and be able to count how many of each PDF has been downloaded.

Real Time Event Labels
Real Time Event Labels

Within a few hours, you should see these in your regular events report under Behaviour -> Events and track file downloads.

Conclusion:

In this post we have shown you how to track file downloads in Google Analytics from anywhere on the site, and dynamically capture the name of the document using GTM V2 and Auto Event Tracking.
Hopefully you can see that if you have a large number of downloads, this is a quick way to setup tracking for them.
From here you can create a Google Analytics Dashboard for easy comparison of MoM and YoY downloads.
Google Tag Managers Variables, previously called Macros, are a powerful feature that can capture all sorts of events and information from a page. The new GTM V2 interface has made the most common ones built in and even easier to use.

Комментариев нет:

Отправить комментарий