The Importance of Video Marketing & Tracking YouTube Player Events: Part

Estimated Reading Time: 3 minutes
November 5, 2012

After 3 weeks of eager anticipation, the third and final part of my “Importance of Video Marketing” series has finally arrived! Part 1 emphasized the importance of video marketing in general. Part 2 described YouTube analytics and how to understand reports.

So what’s left for part 3, you ask? Many digital marketers and web analysts, including ourselves at InfoTrust, like to incorporate all our analysis within Google Analytics. Google Analytics’ robust interface also provides more views of the data and allows for more customization than YouTube analytics.

Without further ado, I’ll briefly leave my marketing persona and turn developer mode on, because implementation is the first part of the battle.

Implementation

1) Place your usual Google Analytics tracking code in your header.

2) Create an empty div element within the body, with an id of “player.” This is where your YouTube video will be placed shortly.

<div id=“player”></div>

3) Next make a script tag and insert the YouTube iframe player API code. Don’t close the script tag yet, however. There’s still more to do!

<script type=“text/javascript”>// <![CDATA[

var tag = document.createElement(‘script’);

tag.src = “http://www.youtube.com/player_api”;

var firstScriptTag = document.getElementsByTagName(‘script’)[0];

firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

4) Now we need to create the iframe and player. Replace the ‘zLQFkztsozw’ with your video ID tag (in the URL), and feel free to customize your video height and width.

     var player;

function onYouTubePlayerAPIReady() {

player = new YT.Player(‘player’, {

height: ‘390’,

width: ‘640’,

videoId: ‘zLQFkztsozw’,

events: {

‘onReady’: onPlayerReady,

‘onStateChange’: onPlayerStateChange

}

});

}

function onPlayerReady(event) {

/// event.target.playVideo();

}

5) Last, use the ‘onPlayerStateChange’ method to look for events, such as the video starting, pausing, finishing, etc. At the end you can finally close that pesky script tag.

     function onPlayerStateChange(event) {

if (event.data ==YT.PlayerState.PLAYING)

{_gaq.push([‘_trackEvent’, ‘Videos’, ‘Play’,

player.getVideoUrl() ]); }

if (event.data ==YT.PlayerState.ENDED)

{_gaq.push([‘_trackEvent’, ‘Videos’, ‘Watch to End’,

player.getVideoUrl() ]); } }

// ]]></script>

Analysis

Great! Time to put that marketing hat back on. Now that your YouTube videos are tracked in Google Analytics, how can you measure their effectiveness?

Tracking Events with Google Analytics

If you follow the path Content > Event > Top Events in Google Analytics, then change your Primary Dimension to Event Label and Secondary Dimension to Event Action, you’ll see something like the screen above. You can now learn how many views (aka events) your embedded video has, how many of them are unique, and how far into each video your viewers go. If you’re seeing a lot of viewers trail off in “Video 25%” or “Video 50%” it’s a good indication your videos are too long. If you see  lot of pauses, consider speaking slower or providing better descriptions so viewers are able to watch your video all the way through.

Now try changing the Secondary Dimension to Content > Page and you’ll see all the pages your YouTube video is being viewed on, and you’ll be able to see which pages are receiving the most events. Or try changing the Secondary Dimension to Visitors > Region to see where most of your views are coming from.

These are just a handful of insights, as you know Google Analytics introduces new features and new insights all the time. Keep exploring your primary and secondary dimensions to learn more!

InfoTrust is a Google Analytics Certified Partner and we love answering questions! If you have any questions, comments, or would like to contact us about our services, feel free to reach out to us at info@infotrustllc.com.

Article written by James Love

Author

  • Jimmy Love is currently the Industry Team Manager for the Healthcare & Fitness Industry Team at InfoTrust. Jimmy was a contributor to InfoTrust’s Crawl, Walk, Run Amazon best-selling book series, and a speaker at the New York City Durability Summit. Jimmy works with some of the largest healthcare and fitness organizations in the world, helping them advance their digital analytics maturity in a forward-thinking and strategic manner.

    When away from his desk, Jimmy enjoys attending Cincinnati Bearcats football and basketball games, and spending quality time with his beautiful wife and dogs.

    View all posts
Last Updated: October 9, 2023

Get Your Assessment

Thank you! We will be in touch with your results soon.
{{ field.placeholder }}
{{ option.name }}

Talk To Us

Talk To Us

Receive Book Updates

Fill out this form to receive email announcements about Crawl, Walk, Run: Advancing Analytics Maturity with Google Marketing Platform. This includes pre-sale dates, official publishing dates, and more.

Search InfoTrust

Leave Us A Review

Leave a review and let us know how we’re doing. Only actual clients, please.

  • This field is for validation purposes and should be left unchanged.