Auto-event tracking in Google Tag Manager (GTM) allows you to automatically track user interactions with your website or app without having to manually add event listeners to every clickable element. GTM’s auto-event tracking is a powerful feature because it enables the tracking of a variety of user actions, such as clicks, form submissions, video interactions, and more, without requiring extensive custom code.
Here’s a step-by-step guide on how to create and use auto-event tracking in Google Tag Manager:
1. Understanding Auto-Event Tracking in GTM
Auto-event tracking involves using built-in GTM features such as Triggers and Variables that automatically detect specific user interactions with your website or app. For example, you can track clicks on buttons, form submissions, link clicks, and even video engagements.
GTM provides the following key triggers for auto-event tracking:
- Click Triggers (for clicks on links, buttons, or other elements)
- Form Submission Triggers (for form submissions)
- Scroll Depth Triggers (for tracking how far down a page users scroll)
- Video Triggers (for interactions with embedded videos, e.g., YouTube or Vimeo)
2. Setting Up Auto-Event Tracking
Let’s go through the process of setting up auto-event tracking in GTM for common use cases:
2.1 Tracking Clicks on Buttons or Links
To track clicks on specific buttons or links, you need to create a Click Trigger in GTM that will fire when a user clicks on an element of interest (e.g., a button or a link).
Steps to Track Button Clicks:
- Go to Google Tag Manager and open your container.
- Create a new Trigger:
- Navigate to Triggers > New.
- Choose the Click – All Elements trigger type. This will capture all click interactions on the page.
- Configure Trigger Conditions:
- Under Trigger Configuration, select Some Clicks if you want to specify which buttons or links to track.
- Define conditions based on the element’s attributes (such as Click Classes, Click ID, or Click Text) to identify which specific elements you want to track. For example:
- Click Classes =
cta-button
(if your button has this class). - Click ID =
submit-button
(if your button has this ID).
- Click Classes =
- Save the Trigger.
- Create a Tag to Fire with This Trigger:
- Create a tag (e.g., a Google Analytics event tag) that will fire when the button is clicked.
- Under the Tag Configuration, choose Google Analytics: Universal Analytics or a similar tag type.
- Set the Track Type to Event, and configure the event category, action, and label (e.g.,
Category: Button Click, Action: Submit, Label: Contact Us Button
). - Attach the Click Trigger you created to this tag.
- Test and Publish:
- Use GTM’s Preview Mode to test the trigger and verify that the event fires correctly when the button is clicked.
- Once tested, publish the container.
2.2 Tracking Form Submissions
Form submissions can be automatically tracked with a Form Submission Trigger. This is useful for tracking when users submit a contact form, a newsletter sign-up, or other types of forms.
Steps to Track Form Submissions:
- Go to GTM and create a new trigger:
- Navigate to Triggers > New.
- Select Form Submission as the trigger type.
- Configure Trigger Conditions:
- Select Some Forms to track only specific forms.
- You can use variables such as Form ID or Form Classes to identify the form you want to track. For example:
- Form ID =
newsletter-form
(if your form has this ID).
- Form ID =
- Save the Trigger.
- Create a Tag to Fire on Form Submission:
- Create a tag (e.g., Google Analytics Event Tag) that fires when the form is submitted.
- Under Tag Configuration, select Google Analytics: Universal Analytics or similar.
- Set Track Type to Event, and configure the event parameters (e.g.,
Category: Form Submission, Action: Contact Form, Label: Newsletter
). - Attach the Form Submission Trigger you created to this tag.
- Test and Publish:
- Test the form submission in GTM’s Preview Mode to ensure the tag fires correctly.
- Once verified, publish the changes.
2.3 Tracking Video Interactions
If you have embedded videos on your site (e.g., YouTube or Vimeo), you can use GTM’s Video Trigger to track interactions such as play, pause, and video completion.
Steps to Track Video Interactions:
- Go to GTM and create a new trigger:
- Navigate to Triggers > New.
- Choose YouTube Video (for YouTube videos) or Vimeo Video (for Vimeo videos).
- Configure the Trigger:
- You can configure the trigger to fire on different video events such as:
- Start (video begins)
- Pause (video is paused)
- Complete (video reaches the end)
- You can also track specific video interactions (e.g., tracking 25%, 50%, 75%, and 100% video completion).
- You can configure the trigger to fire on different video events such as:
- Create a Tag to Fire for Video Interactions:
- Set up a tag (e.g., Google Analytics Event Tag) to fire when a specific video interaction occurs.
- Configure the event parameters (e.g.,
Category: Video Interaction, Action: Play, Label: Intro Video
). - Attach the Video Trigger you created to this tag.
- Test and Publish:
- Test the video interaction tracking using GTM’s Preview Mode to ensure everything is firing as expected.
- Once confirmed, publish the changes.
2.4 Tracking Scroll Depth
Tracking how far users scroll on a page can be useful for understanding user engagement with long-form content.
Steps to Track Scroll Depth:
- Create a new Trigger:
- Go to Triggers > New.
- Select Scroll Depth as the trigger type.
- Configure Trigger Settings:
- You can set up the scroll depth trigger to fire when users scroll down a specific percentage of the page (e.g., 25%, 50%, 75%, or 100%).
- Choose whether to track vertical scrolling (most common) or horizontal scrolling.
- Create a Tag to capture scroll depth:
- Set up a tag (e.g., Google Analytics Event Tag) to fire when users scroll to the specified depth.
- Configure the event parameters to track the scroll interaction (e.g.,
Category: Scroll Depth, Action: 50% Scrolled, Label: Homepage
). - Attach the Scroll Depth Trigger to this tag.
- Test and Publish:
- Test the scroll depth trigger in Preview Mode to ensure it’s firing when users scroll to the configured depths.
- Once verified, publish the container.
3. Using Variables with Auto-Event Tracking
GTM allows you to use Variables to capture dynamic values (e.g., the URL of the clicked link, the ID of a clicked button, etc.). For auto-event tracking, you can use built-in variables such as:
- Click URL
- Click Text
- Click Classes
- Form ID
- Scroll Depth Threshold
These variables allow you to capture additional information about the events, which can be sent to tools like Google Analytics.
4. Testing and Debugging Auto-Event Tracking
Before publishing your changes in GTM, always use Preview Mode to test and debug the auto-event tracking setup. GTM’s Preview Mode lets you see exactly which tags and triggers are firing in real-time, making it easier to identify and fix any issues before the changes go live.
5. Publish Your Container
Once everything is tested and working as expected, publish your container to make the changes live on your website.