Auto-event tracking in Google Tag Manager (GTM) allows you to track user interactions on your website without custom JavaScript code. By using auto-event tracking, you can capture actions like clicks, form submissions, scrolling, and video plays, streamlining your tag setup and providing deeper insights into user behavior.
Here’s a step-by-step guide to creating and using auto-event tracking in GTM:
1. Understand the Auto-Event Triggers Available in GTM
Auto-event triggers in GTM are designed to capture a range of interactions:
- Click triggers: Tracks user clicks on links or other elements.
- Form triggers: Detects form submissions.
- Scroll triggers: Records when users scroll to a specified percentage of a page.
- YouTube video triggers: Captures play, pause, and end events on embedded YouTube videos.
- Timer triggers: Fires after a specified time interval on a page.
2. Enable Built-in Variables for Auto-Event Tracking
To use auto-event triggers effectively, you need to enable GTM’s built-in variables that capture click, form, and other event details.
- Go to Variables in your GTM workspace.
- Click on Configure under Built-In Variables.
- Enable the relevant variables, such as:
- Click variables (e.g., Click ID, Click Classes, Click URL, Click Text).
- Form variables (e.g., Form ID, Form Classes).
- Scroll variables (e.g., Scroll Depth Threshold, Scroll Depth Units).
- Video variables (if tracking YouTube interactions).
Enabling these variables allows GTM to capture details about each interaction, which you can later use for specific targeting in your tags.
3. Set Up Click Tracking with Auto-Event Trigger
To track clicks on specific elements, such as buttons, links, or images, follow these steps:
- Create a New Tag:
- In GTM, go to Tags > New.
- Select Tag Configuration and choose a tracking tag (e.g., Google Analytics 4 Event).
- Name the event (e.g., “Button Click”) and fill in event parameters as needed (e.g., event_category: “Button” and event_label: {{Click Text}}).
- Set Up a Trigger for Clicks:
- Under Triggering, select New.
- Choose Trigger Type > Click – All Elements or Click – Just Links if you want to track only link clicks.
- Configure conditions to target specific clicks, such as clicking on an element with a certain ID or class.
- Save the trigger and assign it to the tag you created.
When a user clicks the specified element, GTM will fire this tag, and you’ll see the data in Google Analytics or other platforms where you’re sending the event data.
4. Set Up Form Submission Tracking
To capture form submissions, use the Form Submission trigger:
- Create a New Tag:
- Go to Tags > New.
- Configure the tag to capture a “Form Submit” event in Google Analytics or other analytics platforms.
- Use built-in variables (e.g., Form ID, Form Classes) to pass information about the form in the event parameters.
- Set Up the Form Submission Trigger:
- In the tag’s Triggering section, click New and choose Form Submission.
- Under Trigger Configuration, select Wait for Tags and specify a time limit to ensure all tags load before firing.
- Use conditions to limit the trigger to specific forms (e.g., only fire when Form ID is “contact-form”).
- Assign this trigger to the tag and save.
This configuration will send data to your chosen analytics platform when users submit the specified form.
5. Track Scroll Depth with GTM’s Scroll Trigger
Tracking scroll depth lets you measure engagement by seeing how far down a user scrolls on a page.
- Create a New Tag:
- In Tags > New, configure a tag to capture a “Scroll Depth” event (e.g., with Google Analytics).
- Name your event (e.g., “Scroll Depth”) and add relevant parameters like scroll depth percentage.
- Set Up the Scroll Depth Trigger:
- In the Triggering section, select Scroll Depth as the trigger type.
- Set scroll thresholds (e.g., 25%, 50%, 75%, and 100%) or choose to trigger based on vertical or horizontal scrolling.
- Save the trigger and assign it to the tag.
When users reach the specified scroll depth, the tag fires and sends data to your analytics platform, providing insights on page engagement.
6. Track YouTube Video Interactions
If your site includes embedded YouTube videos, you can track user interactions like play, pause, and video completion events with the YouTube trigger.
- Create a New Tag:
- Go to Tags > New and configure the tag for a “Video Interaction” event.
- Include relevant event details, such as action (play, pause, complete) and video title.
- Set Up a YouTube Video Trigger:
- Under Triggering, select New and choose YouTube Video as the trigger type.
- Choose which interactions to track, such as Start, Pause, Complete, and specify conditions as needed.
- Save the trigger and assign it to your tag.
When users interact with the video, GTM will send these interactions to Google Analytics or other connected platforms.
7. Configure Timer Trigger for Interval-Based Events
The timer trigger is useful for tracking events based on time spent on a page, such as user engagement or session duration.
- Create a New Tag:
- In Tags > New, configure the tag to track a “Timer Event” and specify the time interval (e.g., 30 seconds).
- Add event parameters such as timer start and end times.
- Set Up the Timer Trigger:
- Go to the tag’s Triggering section, select Timer.
- Set the interval in milliseconds (e.g., 30000 for 30 seconds) and choose how many times to fire the tag.
- Use conditions to restrict the timer to specific pages or users as needed.
The tag will fire based on the specified time interval, allowing you to measure time-based user engagement.
8. Test Auto-Event Tracking with GTM’s Preview Mode
Testing your setup ensures that tags are firing correctly and only under the conditions you specified.
- Click on Preview in GTM to enter Debug Mode.
- Visit your site in Debug Mode and interact with the elements being tracked.
- Verify that tags fire as expected for each auto-event trigger and make adjustments if needed.
9. Publish and Monitor Events in Google Analytics
After verifying that your tags and triggers are working correctly, publish your GTM container.
- Monitor Events in Real-Time in Google Analytics: Go to Real-Time > Events to see the data as it comes in.
- Analyze Event Data Over Time: Review the Behavior > Events report to understand how users interact with different elements on your site.
Conclusion
Auto-event tracking in GTM simplifies tracking interactions on your site without the need for complex code. By following the steps above, you can track clicks, form submissions, scroll depth, video interactions, and timer-based events efficiently. With GTM’s Preview Mode and real-time monitoring in Google Analytics, you can ensure that your event tracking is accurate and provides valuable insights into user behavior.