How to track video events in Google Tag Manager?

Image of Iron Brands

Published on Sep 20, 2023 and edited on Dec 12, 2023 by Iron Brands

Tracking video plays gives you insights on user engagement with your video content on your site. With it you can gather valuable insights into their behavior and improve your content.

In this article, we'll show you the easiest way to set this up.

Let's dive in!

  1. Set up video tracking events
  2. Add video tracking with Google Tag Manager
  3. Tigger video tracking events
  4. Final Thoughts
Logo of MichelinMichelin chose Simple AnalyticsJoin them

Set up video tracking events

We will use Simple Analytics in combination with Google Tag Manager instead of Google Analytics. Using these tools setting up video tracking is 10x easier than using GA4.

Suppose you have a video on your website and want to track both when users start playing it and when they finish watching it. We'll demonstrate this process for YouTube videos, but it should apply to other video platforms too.

We have created a demo website with an embedded video to show you how to track video events.

video-test.png

Add video tracking with Google Tag Manager

Follow these steps to set up Google Tag Manager with Simple Analytics to track video events:

  1. Open Google Tag Manager and create a new tag called "Video Events."
  2. Set up a custom trigger for YouTube videos by clicking the "+" button in the top right corner and selecting "YouTube Video" from the list.

video-trigger.png

  1. Enable "Start" and "Complete" events and ensure that "JavaScript API" is enabled in the "Advanced" section.

video-javascript-enable.png

  1. Save the trigger configuration.
  2. In the "Video Events" tag, add the custom HTML code snippet as shown below.

<script>
  if (window.sa_event) {
    sa_event("video_{{Video Status}}", {
      video_provider: "{{Video Provider}}",
      video_title: "{{Video Title}}",
      video_url: "{{Video URL}}"
    })
  }
</script>

This checks if the "sa_event" function is available and sends video events ("video_start" and "video_complete") to Simple Analytics using variables like "Video Status," "Video Provider," "Title," and "URL."

  1. Save the tag configuration and go to "Variables" to configure the built-in variables for these video events.

video-variables.png

  1. Select "Provider," "Status," "URL," and "Title" under the "Video" section.
  2. Save the variable configuration, submit your changes, and publish them to Google Tag Manager.

Tigger video tracking events

Once you've set everything up, you should refresh your website an play the video to the end to trigger the events.

Check your Simple Analytics dashboard's "Events Explorer" to see the recorded video start and complete events with metadata such as provider, title, and URL.

video-dashboard.png

Final Thoughts

With this setup, you can effectively track video engagement on your website and use the collected data to improve your site's user experience and content strategy.

Simple Analytics is a website analytics tool that lets you track your most important metrics in a straightforward dashboard. You don't need the complexity of GA4. Check our live analytics dashboard to see for yourself.

GA4 is complex. Try Simple Analytics

GA4 is like sitting in an airplane cockpit without a pilot license

Start 14-day trial