Setting Up Event Tracking in Google Tag Manager: A Complete Walkthrough

Setting Up Event Tracking in Google Tag Manager: A Complete Walkthrough

Event tracking is a crucial aspect of website analytics that allows you to measure specific user interactions on your site. While basic pageview tracking provides valuable data, event tracking takes your analytics to the next level by giving you detailed insights into how users engage with particular elements of your pages.

Google Tag Manager (GTM) is a powerful tool that makes implementing event tracking much easier, especially for marketers and analysts who may not have advanced coding skills. With GTM, you can set up sophisticated event tracking without having to edit your website’s source code directly.

In this comprehensive guide, we’ll walk through the entire process of setting up event tracking in Google Tag Manager, from the initial setup to advanced implementation techniques. We’ll cover:

  • Understanding the basics of event tracking
  • Configuring GTM for event tracking
  • Setting up common types of event tracking
  • Testing and troubleshooting your event tracking
  • Best practices and tips for effective event tracking

By the end of this walkthrough, you’ll have the knowledge and skills to implement robust event tracking on your own website using Google Tag Manager.

Understanding Event Tracking

Before diving into the technical implementation, it’s important to understand what events are in the context of website analytics and why tracking them is valuable.

An event is any distinct, trackable action that a user takes on your website. Some common examples include:

  • Clicking a button or link
  • Submitting a form
  • Watching a video
  • Scrolling to a certain depth on a page
  • Downloading a file
  • Interacting with a custom element (e.g. opening an accordion)

Unlike pageviews, which are automatically tracked by default in most analytics platforms, events require specific configuration to capture. This is because events can be highly customized and unique to each website’s particular elements and goals.

The value of event tracking lies in the detailed insights it provides about user behavior and engagement. With event tracking, you can answer questions like:

  • How many users clicked on a specific call-to-action button?
  • What percentage of visitors watch your product demo video?
  • Which form fields cause the most drop-offs?
  • Do users scroll all the way to the bottom of your long-form content?

This granular data allows you to measure the effectiveness of specific page elements, identify areas for improvement in your user experience, and ultimately optimize your site for better performance and conversions.

In Google Analytics, events are typically composed of four components:

  1. Category – A broad grouping for the event (e.g. “Videos”, “Downloads”)
  2. Action – The specific action taken (e.g. “Play”, “Pause”, “Click”)
  3. Label – Additional details about the event (e.g. video name, button ID)
  4. Value – An optional numerical value associated with the event

These components allow you to organize and analyze your event data in meaningful ways within your analytics reports.

Now that we understand the basics of event tracking, let’s look at how to set it up using Google Tag Manager.

Prerequisites for Event Tracking in Google Tag Manager

Before you start implementing event tracking, there are a few important steps to take in your Google Tag Manager account:

1. Enable Built-in Variables

GTM provides a set of built-in variables that are incredibly useful for event tracking. To enable them:

  1. In your GTM container, click on “Variables” in the left sidebar
  2. Under “Built-in Variables”, click “Configure”
  3. Check the boxes to enable all variables in these categories:
  • Pages
  • Clicks
  • Forms
  • Videos
  • Scrolling
  • Visibility

Enabling these variables will give you access to a wide range of pre-configured options when setting up your event triggers and tags.

2. Set Up Google Analytics Connection

If you haven’t already, you’ll need to set up your Google Analytics connection in GTM:

  1. Go to “Variables” and create a new “Google Analytics Settings” variable
  2. Enter your Google Analytics property ID
  3. Configure any additional settings as needed (e.g. custom dimensions)

This variable will be used when creating your event tags to send data to Google Analytics.

3. Familiarize Yourself with CSS Selectors

Many event tracking setups rely on CSS selectors to identify specific elements on your page. While you don’t need to be a CSS expert, understanding basic selector syntax will be very helpful. Some key concepts to know:

  • IDs are prefixed with # (e.g. #submit-button)
  • Classes are prefixed with . (e.g. .nav-link)
  • You can target elements by their HTML tag (e.g. buttona)
  • Combinators like > and spaces allow you to target nested elements

If possible, work with your web developers to ensure important elements on your site have unique IDs or classes for easy targeting.

With these prerequisites in place, you’re ready to start setting up event tracking in GTM.

Setting Up Event Tracking Triggers

Triggers are a fundamental concept in Google Tag Manager. They define the conditions under which your tags (including event tracking tags) will fire. For event tracking, we typically use click triggers, form submission triggers, and custom event triggers.

Let’s walk through setting up some common event tracking triggers:

Click Trigger for Button Tracking

To track clicks on a specific button:

  1. In GTM, go to “Triggers” and click “New”
  2. Choose “Click – All Elements” as the trigger type
  3. Under “This trigger fires on”, select “Some Clicks”
  4. Set up your conditions. For example:
  • Click ID equals submit-button
  • OR
  • Click Class contains cta-button
  1. Name your trigger (e.g. “Main CTA Button Click”) and save

This trigger will now fire whenever a user clicks on an element matching your specified conditions.

Form Submission Trigger

To track form submissions:

  1. Create a new trigger and choose “Form Submission” as the type
  2. Leave “Wait for Tags” and “Check Validation” enabled
  3. Under “This trigger fires on”, you can choose:
  • “All Forms” to track every form submission
  • “Some Forms” to specify conditions (e.g. Form ID equals contact-form)
  1. Name and save your trigger

Scroll Depth Trigger

To track how far users scroll down your pages:

  1. Create a new trigger and choose “Scroll Depth” as the type
  2. Choose whether to track vertical scroll depth, horizontal, or both
  3. Set your scroll percentages (e.g. 25%, 50%, 75%, 100%)
  4. Optionally, set pixel depth thresholds
  5. Choose whether this should fire on all pages or only specific ones
  6. Name and save your trigger

Custom Event Trigger

For more complex interactions, you may need to use custom JavaScript events:

  1. Create a new trigger and choose “Custom Event” as the type
  2. Enter the event name that will be pushed to the data layer (e.g. videoPlay)
  3. Optionally, add conditions to filter when this event should fire
  4. Name and save your trigger

Custom events require additional setup in your website’s code to push events to the data layer, which we’ll cover later in this guide.

With your triggers set up, you’re ready to create the tags that will send your event data to Google Analytics.

Creating Event Tracking Tags

Tags in Google Tag Manager are responsible for sending your event data to Google Analytics (or other analytics platforms). Here’s how to set up a basic event tracking tag:

  1. In GTM, go to “Tags” and click “New”
  2. Choose “Google Analytics: Universal Analytics” as the tag type
  3. For “Track Type”, select “Event”
  4. Fill in your event tracking parameters:
  • Category: Enter a broad category for the event (e.g. “Button Clicks”)
  • Action: Describe the action (e.g. “Click”)
  • Label: Add additional details (e.g. {{Click Text}} to capture the button text)
  • Value: Optionally, enter a numeric value or variable
  1. Under “Google Analytics Settings”, select your GA variable
  2. In the “Triggering” section, select the appropriate trigger you created earlier
  3. Name your tag descriptively and save

Repeat this process for each event you want to track, adjusting the parameters and trigger as needed.

Using Variables in Event Tags

GTM’s built-in and user-defined variables can make your event tracking more dynamic and informative. Some useful variables to consider:

  • {{Page Path}} – Captures the current page path
  • {{Click URL}} – For tracking link clicks, captures the destination URL
  • {{Click Text}} – Captures the text of the clicked element
  • {{Form ID}} – Useful for differentiating between multiple forms

You can use these variables in your event parameters to capture more detailed information about each event.

Non-Interaction Events

For events that don’t indicate active engagement (e.g. automatic video plays), you may want to set the “Non-Interaction Hit” option to “True” in your event tag. This prevents these events from affecting your bounce rate calculations in Google Analytics.

Advanced Event Tracking Techniques

Once you’re comfortable with basic event tracking, you can explore more advanced techniques to capture richer data:

Video Tracking

To track video engagement:

  1. Use the YouTube Video trigger type for YouTube embeds
  2. For other video players, you may need to use custom JavaScript to push events to the data layer
  3. Create triggers for actions like play, pause, progress milestones, and completion
  4. Set up corresponding tags to send this data to Google Analytics

Enhanced Ecommerce Events

For ecommerce sites, consider implementing enhanced ecommerce tracking:

  1. Use the data layer to push detailed product and transaction data
  2. Create triggers for actions like product clicks, add to cart, remove from cart, and purchases
  3. Use the Google Analytics: Universal Analytics tag type with “Enable Enhanced Ecommerce Features” turned on

Custom Metric Tracking

To track more complex interactions:

  1. Use custom JavaScript variables to calculate metrics (e.g. time on page, scroll percentage)
  2. Push these values to the data layer with custom events
  3. Create triggers and tags to capture and send this data to Google Analytics

Remember, with great power comes great responsibility. While it’s tempting to track everything, focus on the events that align with your business goals and provide actionable insights.

Previewing and Testing Event Tracking

Before publishing your event tracking setup, it’s crucial to thoroughly test everything using GTM’s preview mode:

  1. Click the “Preview” button in GTM
  2. Navigate to your website in a new tab
  3. You should see the GTM debug panel at the bottom of the page
  4. Interact with your site and watch for your triggers firing in the debug panel
  5. Click on fired tags to verify the event data being sent

Use Google Analytics’ Real-Time reports to confirm that events are being received correctly:

  1. In Google Analytics, go to Real-Time > Events
  2. Perform the actions on your site that should trigger events
  3. Watch for the events to appear in the real-time report
  4. Verify that the Category, Action, and Label match your expectations

If you don’t see your events firing or appearing in Analytics, double-check your trigger conditions, tag configuration, and any custom JavaScript you’re using.

Best Practices for Event Tracking

To get the most out of your event tracking implementation, keep these best practices in mind:

  1. Plan your event structure: Before implementing, create a clear plan for your event categories, actions, and labels. Consistent naming conventions will make analysis much easier.
  2. Use descriptive names: Choose clear, descriptive names for your triggers and tags in GTM. This will help you and your team understand the setup at a glance.
  3. Leverage the data layer: For complex interactions, use the data layer to pass detailed information to GTM. This provides more flexibility and reliability than relying solely on DOM scraping.
  4. Minimize redundant events: Avoid tracking every tiny interaction. Focus on events that provide meaningful insights into user behavior and business goals.
  5. Regular audits: Periodically review your event tracking setup to ensure everything is still working correctly and that you’re not tracking obsolete events.
  6. Document your setup: Maintain clear documentation of your event tracking implementation, including the purpose of each event, how it’s triggered, and where the data can be found in your reports.
  7. Consider data privacy: Ensure your event tracking complies with data privacy regulations like GDPR and CCPA. Avoid capturing personally identifiable information in your events.

Conclusion

Event tracking in Google Tag Manager is a powerful way to gain deeper insights into how users interact with your website. By following this guide, you should now have a solid foundation for implementing event tracking, from basic click tracking to more advanced custom events.

Remember that effective event tracking is an ongoing process. Regularly review your data, identify new opportunities for tracking, and refine your implementation to ensure you’re capturing the most valuable insights for your business.

With practice, you’ll become proficient at using GTM for event tracking, opening up new possibilities for data-driven decision making and website optimization.

Frequently Asked Questions (FAQ)

Q: What types of events can be tracked using Google Tag Manager? A: GTM can track a wide variety of events, including button clicks, form submissions, video interactions, scroll depth, file downloads, and custom events defined by your own JavaScript.

Q: Is it necessary to enable built-in variables before event tracking? A: While not strictly necessary, enabling built-in variables makes event tracking much easier by providing access to commonly used data points without additional configuration.

Q: How do I set up event tracking in Google Analytics? A: Event tracking is set up in Google Analytics by creating tags in Google Tag Manager that send event data to your GA property. You’ll need to configure the event category, action, and label in your GTM tags.

Q: Do I need to track every event through Google Tag Manager? A: No, you should focus on tracking events that provide meaningful insights for your business goals. Tracking too many insignificant events can lead to data overload and slower site performance.

Q: What variables can be used for event tracking parameters? A: Common variables include Page Path, Click URL, Click Text, Form ID, and custom JavaScript variables. You can also create your own user-defined variables in GTM.

Q: How can I ensure event tracking doesn’t affect bounce rate? A: For events that don’t indicate active engagement, set the “Non-Interaction Hit” option to “True” in your event tag. This prevents the event from affecting bounce rate calculations in Google Analytics.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *