Google Analytics Events

This article explains how to use auto-event tracking to generate Google Analytics events

If auto-event tracking does not meet the needs of your scenario, you can manually trigger events from your code.

Note: In Google Tag Manager v2, Auto-Event Listener Tags will disappear and their functionality will be folded into Events.

GTM only fires tags in response to events. This wasn’t obvious in the previous version of Google Tag Manager because you didn’t need to specify an event for your tag: GTM would assume you meant “fire on startup” if you omitted an event. This led to confusion for people who didn’t understand why their tags weren’t firing or were firing at the wrong time. Auto-Event Tracking made the situation even more complicated by having tags that generated events.

The new model makes GTM’s event-driven approach clear, and simplifies Auto-Event Tracking.

For the purposes of this discussion, imagine that every page on your site has a navigation menu that allows you to go to the "Buy" page, the "About" page, or the "Contact" page, depending upon which navigation item is selected. The "Buy" selection links to "http://example.com/buy.html". "About" links to "http://example.com/about.html". "Contact" links to "http://example.com/contact.html". You want to generate a Google Analytics event each time someone clicks one of these navigation items.

  1. Add a basic page tracking tag (i.e. Tag Type of Google Analytics or Universal Analytics; Track Type of Page View) if you don't already have one. This tag must fire on all pages.
  2. Create a new Trigger:
    1. Type: Click
      NOTE: Creating a ‘Click’ trigger will automatically enable GTM Auto-Event Listening for the container upon publishing. Learn more about event triggers.
    2. Filter: URL contains buy.html
    3. Trigger Name: Buy Clicks
    4. Trigger Type: Just Links
    5. Wait for tags: Check
    6. Max wait time: [enter appropriate time here, e.g. 2000ms]
  3. For each link, add a Google Analytics event tracking tag and set the firing condition to the ‘Buy Clicks’ trigger configured above. For example:
    1. Tag: Google Analytics
    2. Triggers: Click
      1. Name: Buy Clicks
    3. Tag Name: UA - Event - Buy Link
    4. Tag type: Universal Analytics
    5. Track Type: Event
      1. Category: Nav
      2. Action: Select
      3. Label: Buy
  4. Save and publish container

All Clicks

Imagine that your webpage contains elements that users might click which are not traditional links. You want to generate a Google Analytics event each time someone clicks HTML elements with a certain Element ID, for example, clicks on an image with the ID ‘Gallery_Image’.

  1. Add a basic page tracking tag (i.e. Tag Type of Google Analytics or Universal Analytics; Track Type of Page View) if you don't already have one. This tag must fire on all pages.
  2. Create a new Trigger:
    • Type: Click
    • Filter: Element ID contains Gallery_Image
    • Trigger Name: Gallery Image Clicks
    • Trigger Type: All elements
      NOTE: Creating a ‘Click’ trigger will automatically enable GTM Auto-Event Listening for the container upon publishing. Learn more about event triggers.
  3. Add an Analytics event tracking tag (i.e. Tag Type of Google Analytics or Universal Analytics; Track Type of Event). Add the trigger you created in the previous step (for example, "Gallery Image Clicks"). Enter a Category, Action, and and Label for the event. For example, you might use the following:
    • Category "All"
    • Action "Click"
    • Label "All".
  4. Save a version of the container and publish it.

Timed Intervals

Imagine that you have a page where users might spend a significant amount of time without triggering any events, for example a page where a video is viewed. Given that Google Analytics sessions timeout after 30 minutes by default, you may wish to implement a ‘keepalive event’ to ensure that activity is sent every 25 minutes. For this purpose, you may use a GTM Timer:

  1. Add a basic page tracking tag (i.e. Tag Type of Google Analytics or Universal Analytics; Track Type of Page View) if you don't already have one. This tag must fire on all pages.
  2. Create a new Trigger:
    • Type: Timer
      NOTE: Creating a Timer trigger will automatically enable GTM Auto-Event Listening for the container upon publishing. Learn more about event triggers.
    • Filter: URL matches RegEx .*
    • Trigger Name: Session Timer
    • Event Name: gtm.timer
    • Interval: 1500000
    • Limit: 5
  3. Add an Analytics event tracking tag (i.e. Tag Type of Google Analytics or Universal Analytics; Track Type of Event). Add the trigger you created in the previous step (for example, "Session Timer"). Enter a Category, Action, and and Label for the event.
  4. Save a version of the container and publish it.

Form Submit

Imagine that you want to record all submissions of a form on your site with the Element ID ‘My_Form’:

  1. Add a basic page tracking tag (i.e. Tag Type of Google Analytics or Universal Analytics; Track Type of Page View) if you don't already have one. This tag must fire on all pages.
  2. Create a new Trigger:
    • Type: Form
      NOTE: Creating a Form trigger will automatically enable GTM Auto-Event Listening for the container upon publishing. Learn more about event triggers.
    • Filter: Element ID contains My_Form
    • Trigger Name: My Form Submit
    • Wait for tags: Check
    • Max wait time: [enter appropriate time here, e.g. 2000ms]
  3. Add an Analytics event tracking tag (i.e. Tag Type of Google Analytics or Universal Analytics; Track Type of Event). Add the trigger you created in the previous step (for example, "My Form Submit"). Enter a Category, Action, and and Label for the event. For example, you might use the following:
    • Category "Forms"
    • Action "Submit"
    • Label "Lead Gen".
  4. Save a version of the container and publish it.
Was this article helpful?