Skip to content

Tracking HTML5 Video in Healthcare Websites with Google Tag Manager

Leveraging Video Content for Visibility in Healthcare 

As Google’s algorithm evolves, it has increasingly favored content that reflects Expertise, Experience Authoritativeness, and Trustworthiness (EEAT). For healthcare providers aiming to climb higher on SERPs, producing content that Google deems credible and trustworthy is essential. One of the most impactful ways to achieve this is through the strategic use of videos on condition pages, service pages, and homepages. These videos can serve multiple purposes: illustrating the type of care provided, establishing a rapport and trust with potential patients, or offering in-depth explanations about specific medical conditions. This approach not only enriches the user experience but also significantly boosts the EEAT signals for Google, enhancing the provider’s online visibility and credibility.

Incorporating such valuable content is only the first step; it is equally crucial to track and analyze how these videos are interacted with by users. This is where Google Tag Manager (GTM) comes into play, specifically for HTML5 video tracking. By implementing the steps outlined in this article for setting up video tracking, healthcare providers can gain insights into key performance indicators like which videos are most watched, whether viewers are watching these videos to the end, and how these videos are influencing the site’s conversion goals. This data is invaluable, as it not only helps in understanding patient engagement but also guides content strategy to further strengthen EEAT signals. By leveraging GTM for HTML5 video tracking, healthcare providers can ensure they are making the most of their digital content strategy, ultimately leading to improved patient trust and engagement.

What is the HTML5 <video> Element? 

The HTML5 <video> element specifies a standard way to embed a video in a web page. Before HTML5 defined this specification, a video would typically only be played in a browser with a plug-in (like Adobe Flash).

As an analyst or digital strategist, you want to know how these kinds of videos perform and how they are used on a given website. You want to answer the following key performance indicators:

  • Which videos are the most watched? 
  • Are the videos viewed to the end? 
  • Does video make an impact on the conversion goals of my site?

Note: This article does not cover YouTube, Vimeo, Brightcove, or other third-party video solutions – if your site is using one of these solutions, different tagging methodology would be used and is not covered here. This article only applies to HTML5 embedded <video> objects as in the example below.

Step-by-step guide

Given following example HTML5 video element:

<video controls data-title="The Video Title"onpause="sendEvent('Pause', this)"onplay="sendEvent('Play', this)"onended="sendEvent('Ended', this)">
    <source src="somevideo.mp4"type="video/mp4">
</video>
  1. Confirm Videos Have Data Elements for Video Tracking: Note the following 4 attributes set on this element – we’ll use this to drive the analytics and tagging. (If your embedded HTML5 video does not have these attributes, you’ll need to have them added.)
    data-title, onpause, onplay, onended
  2. Set Up Event Handler Function for Video Tracking: You will deploy the following handler function to the site. (This can be done by adding this code to the page as a <javascript> element, or injecting the function through Tag Manager.)
    function sendEvent(action, element) {
        var videoTitle = $(element).data('title');
        if (dataLayer && videoTitle) {
            dataLayer.push({
                'event': 'gtm.custom_event',
                'eventInfo': {
                    'category': 'Video',
                    'action': action,
                    'label': element,
                    'value': 0,
                    'nonInteraction': false
                }
            });
        }
    }
  3. Download Container File: Download the Google Tag Manager tracking recipe (right-click on the link and click “Save Link As” or “Save Target As” to save the JSON file to your computer).
  4. Import JSON File into Google Tag Manager: Log into your own Google Tag Manager container and navigate to the Admin section. Under Container options, select Import Container
  5. Update with Your Own Tracking ID: In Google Tag Manager, update the Constant Variable named {{ UA-XXXXX }} with your Google Analytics Tracking ID.
  6. Verify Event Tracking Taxonomy in Google Tag Manager: This configuration uses the corresponding action verb (‘Play’, ‘Pause’, ‘Ended’) from the event handler attributes (onpause, onplay, onended) to set the Event Action for the Google Analytics tag. It uses the value in the data-title attribute as the Event Label.
  7. Preview, Test, & Publish Tracking for Video Events: Test your tagging by playing, pausing, and watching the video to completion. You should see tracking in Google Analytics Events for each of the corresponding actions along with the video name.

By meticulously tracking video performance with Google Tag Manager, healthcare providers can ensure they are creating content that resonates with users and effectively boosts EEAT signals. Armed with this data, providers can continuously refine their content strategy to align with Google’s evolving standards.

If you have any questions about this process or related topics, we’d love to hear from you!

Description of the image