Event Listeners in Tag Manager

by Luca Rabboni

facebooktwittergoogle_pluspinterestlinkedintumblr

With Tag Manager now you can setup Events without implement any additional code to your CMS. You find these feature under the Event Listener submenu when you add a new tag from your GTM container.

GTM Type of Event Listener Tags are:

  • Click Listener
  • Form Submit Listener
  • Link Click Listener
  • Timer Listener

Let’s make an example!

Suppose you want to track links or buttons with event tracking in Google Analytics. Here’s what you have to do:

1. CREATE AN EVENT LISTENER TAG

First of all, add a tag with type Event Listener > Link Click Listener. Alternatively, if the element you want to track is not a link (for example a button, you can use Click Listener, which works the same way, but on any element.)
Picture3
Second you have to set a rule for this tag that will fire fire it on all pages.
Picture4

Whenever someone clicks on a link, GTM creates an event in your data layer. The event is called gtm.linkClick for Link Click Listener (or gtm.click for Click Listener). You will use it in a GTM rule to fire a GA tag in the next step.

The information in the data layer also includes a bunch of properties about what was clicked, including the entire HTML element, its ID, class, and the URL of the link. You can use those elements to create macros for gathering data in GA

2. CREATE A GOOGLE ANALYTICS EVENT TAG

Add a tag with type Google Analytics. Note that this is in addition to the tag you’ve already created to track your pageviews. This additional tag will track events.

Select “Event” as the Track Type. Fill in “Category”, “Action” and “Label” with the information you’d like to send to your GA Event reports (you can also use macros to capture some of the information about the element that was clicked.
Picture6

Create rules to fire this tag. At a minimum, you need to fire the tag when the event gtm.linkClick (or gtm.click) occurs in the data layer. But keep in mind that this will occur any time any link (or element) is clicked.You might want to be more specific. For example, suppose we only wanted to track links to DOCs

Here’s a rule that does that: GTM DOC Click Rule

File types: {{event}} equals gtm.linkClick and {{element url}} ends with .doc

Picture8
3. PREVIEW AND PUBLISH

As with all GTM changes, you’ll want to create a new version, preview it on your site to make sure it’s working correctly, and finally publish it live.