Search
Clear search
Close search
Google apps
Main menu

Google Analytics events

In this article:

Google Tag Manager only fires tags in response to events. This article explains how to use auto-event tracking to generate Google Analytics tags that are triggered...

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

Note on Tag Manager variables: A value in a trigger or tag is a Tag Manager variable when they are wrapped in double brackets. For example: “Label: {{Click Text}}” denotes a variable as the value of the label field. “Label: Buy” denotes plain text entered by the user as the value of the label field. 

Note on the difference between Google Analytics events and Google Tag Manager events: Analytics events are hits sent as the result of Analytics tags fired from Tag Manager. Tag Manager browser events are user interactions with web page elements ("DOM elements") that are registered by the browser and pushed into the Tag Manager data layer so that they may be used to set up triggers.

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".

The goal is to generate a Google Analytics event each time someone clicks one of these navigation items, so that they can be tracked individually. There are two methods for how to set this up shown here: One that uses separate triggers and tags for each type of link, and one that uses a regular expression to combine all click tracking into one single trigger and tag.

Set up click tracking using separate triggers and tags

  1. Add a basic Google Analytics page tracking tag if you don't already have one. This tag must fire on all pages.
  2. Enable Tag Manager to capture clicked URL values. Navigate to ‘Variables’ on the left-hand navigation and check the box next to the ‘Click URL’ built-in variable.
  3. Create triggers to track link clicks for buy.html, contact.html, and about.html:
    1. Navigate to ‘Triggers’ on the left-hand navigation and create a new Trigger with the following settings:
      • Type: Click
      • Targets: Just Links
      • Wait for tags: Check
      • Max wait time: (use the default value of 2000ms)
      • Check Validation: Uncheck
      • Enable When: Click URL contains buy.html
      • Fire On: All Clicks
      • Save Trigger as “Buy Clicks”
    2. Repeat these steps for “contact.html” and “about.html”
  4. For each link, add a new Google Analytics event tracking tag and set the firing conditions to the corresponding triggers configured above. For example:
    1. Start by creating a tag to track clicks on the Buy links. Navigate to ‘Tags’ on the left-hand navigation and create a new tag with the following settings:
      • Tag: Universal Analytics
      • Triggers: Click
      • Name: Buy Clicks
      • Tag Name: UA - Event - Buy Link
      • Tag type: Universal Analytics
      • Track Type: Event
      • Category: Nav
      • Action: Select
      • Label: Buy
        NOTE: The Label value should correspond to the particular link being clicked (e.g. Buy for buy.html, Contact for contact.html, and About for about.html).
    2. Save the tag as “Nav Clicks”.
    3. Repeat for the Contact and About links.
  5. Publish

Set up click tracking using a single tag

An alternate method for measuring the same clicks can be achieved by using a regular expression on a single trigger and tag.

  1. Add a basic Google Analytics page tracking tag if you don't already have one. This tag must fire on all pages.
  2. Enable Tag Manager to capture clicked URL values. Navigate to ‘Variables’ on the left-hand navigation and check the box next to the ‘Click URL’ built-in variable.
  3. Create one trigger for link clicks for buy.html, contact.html, and about.html.
    1. Navigate to ‘Triggers’ on the left-hand navigation and create a new Trigger with the following settings:
      • Type: Click
      • Targets: Just Clicks
      • Wait for tags: Check
      • Max wait time: [enter appropriate time here, e.g. 2000ms]
      • Check Validation: Uncheck
      • Enable When: ‘Click URL’ matches RegEx contact\.html|buy\.html|about\.html
      • Fire On: All Clicks
    2. Save trigger as “GA - Trigger - Nav Clicks”
  4. Create a new Tag to handle all navigation clicks:
    1. Navigate to ‘Tags’ on the left-hand navigation
      • Product: Google Analytics
      • Tag Type: Universal Analytics
      • Enter Tracking ID
      • Track Type: Event
      • Category: Nav
      • Action: Click
      • Label: {{Click URL}}
      • Apply the trigger “GA - Trigger - Nav Clicks” to the tag
    2. Save the new tag as “GA - Event Tag - Nav Clicks”
  5. Publish.

Clicks on any specified element type

Imagine that your webpage contains elements that users might click which are not traditional links. This could be an image, a <div> element, or any other item on the page accessible by the DOM. This technique will generate a Google Analytics event each time someone clicks on one of these elements. For this example, we will assume clicks on an image with a class of Gallery_Image:

  1. Add a basic Google Analytics page tracking tag if you don't already have one. This tag must fire on all pages.
  2. Enable Tag Manager to capture the class of a given element.
    1. Click "Variables" in the left navigation.
    2. Under "Built-In Variables", click "Configure".
    3. Check "Click Classes".
  3. Create a new Trigger:
    1. Navigate to ‘Triggers’ on the left-hand navigation and create a new Trigger with the following settings:
      • Type: Click
      • Targets: All Elements
      • Fire On: Some Clicks
      • Click Class contains Gallery_Image.
    2. Save the trigger as ‘GA - Trigger - Gallery Image Click’
  4. Create a new Tag:
    1. Navigate to ‘Tags’ on the left-hand navigation
      • Tag: Universal Analytics
      • Enter Tracking ID
      • Category: Image Gallery
      • Action: Click
      • Label: {{Click ID}}
      • Apply the trigger ‘GA - Trigger - Gallery Image Click’ to the tag
    2. Save the tag as ‘GA - Event Tag - Gallery Image Click’
  5. Publish.

Timed intervals

Note on implementing timed intervals: Timed interval tracking may influence your bounce rate calculations in Analytics, possibly resulting in a lower bounce rate.

Tracking timed intervals can be used used when you have a page where users might spend a significant amount of time without triggering any events, such as a page with embedded video, and you would like to track how long users are on the page. Additionally, 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 Google Analytics page tracking tag if you don't already have one. This tag must fire on all pages.
  2. Create a Timer Trigger:
    1. Navigate to ‘Triggers’ on the left-hand navigation and create a new Trigger with the following settings:
      • Type: Timer
      • Enable When: URL matches RegEx .*
      • Event Name: gtm.timer
      • Interval: 1500000
      • Limit: 5
    2. Save the Trigger as “GA - Trigger - Session Timer”
  3. Create a session timer tag:
    1. Navigate to ‘Tags’ on the left-hand navigation and create a new tag with the following settings:
      • Tag: Universal Analytics
      • Enter Tracking ID
      • Track Type: Timing
      • Apply the trigger “GA - Trigger - Session Timer” to the tag
    2. Save the tag as “GA - Timer Tag - Session Timer”
  4. Publish.

Form submits

This technique will cause a tag to fire every time a form is submitted. For this example, we want to record all submissions of a form with the Element ID "My_Form":

  1. Add a basic page tracking tag (e.g. 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. Enable Tag Manager to capture form IDs. Navigate to ‘Variables’ on the left-hand navigation and check the ‘Form ID’ built-in variable.
  3. Create a form submit trigger:
    1. Navigate to ‘Triggers’ on the left-hand navigation
    2. Create a new Trigger with the following values:
      • Type: Form Submission
      • Wait for Tags: unchecked
      • Check Validation: unchecked
      • Fire On: Some Forms
      • Form ID contains My_Form
        NOTE: The Form ID built-in variable must be enabled before it will show up as a Fire On option.
    3. Save the trigger as “GA - Trigger - My Form Submits”
  4. Navigate to ‘Tags’ on the left-hand navigation
    1. Create a new Tag
      • Product: Google Analytics
      • Tag Type: Universal Analytics
      • Enter Tracking ID
      • Category: Forms
      • Action: Submit
      • Label: Lead Gen - {{Form ID}}
      • Apply the “GA - Trigger - My Form Submits” trigger to the tag
    2. Save the tag as “GA - Form Submit Tag - My Forms”
  5. Publish.
Was this article helpful?
How can we improve it?