Track YouTube Videos in Marketo

Track YouTube Videos in Marketo

Track YouTube Videos in Marketo

Many of our clients host marketing videos, recorded webinars, or other video content on YouTube. It’s simplicity and dominance in the online video space make it the de facto standard for many marketers.

No Marketo integration with YouTube’s standard embed code

Despite its ease of use, however, many Marketo practitioners have been frustrated that they have no visibility from within Marketo to leads’ interactions with their YouTube video content. For this one feature, many marketers utilize video hosting solutions like VidYard to get video interaction information into Marketo.

But there is another way, and it is much easier on your budget.

Track YouTube videos in Marketo with Javascript APIs

Our team at Digital Pi has developed and refined a simple script that you can include—for free!—in your Marketo landing pages to embed a YouTube video and get key video interaction data back into Marketo. This data can then be used to change program statuses, increase leads’ behavior scores, or anything else that can be added to a workflow in Marketo.

One of the key features of the script is that you can see which leads reached self-defined video to milestones.

Example scenario: let’s say you have a product demo video and a corresponding Marketo program based on your Product Marketing channel.

  1. When a known lead views the landing page, her program status is set to Member.
  2. When she views 50% of the video, that milestone is logged and triggers a program status change to Interested.
  3. When she views 100% of the video, the program status changes to Engaged.
  4. At this point, you could have the landing page generate a modal popup with a Marketo form to request a free sample kit, because you know she is likely ready to try it out.

A simple demo

Here is an example video. Below it is a log that shows what information is sent to Marketo. Feel free to play and pause the video to watch what happens as the information is logged. As you watch the video, look for milestones to automatically show up in the log at 25%, 50% and 75% completion.

By the way, this all works on both Android and iOS mobile devices too. I recommend testing on all platforms.

click actions logged to Marketo (scrollable):

Play the video above to see your interactions logged here.

The YouTube tracking script

Here is the script: Digital Pi’s YouTube tracking script for Marketo

To use the script, you will need to make a few changes to your Marketo landing page template(s) where you want to use the video functionality:

  1. Include this script just before the closing </body> tag:<script src=””></script>(I recommend saving the script to your computer, uploading it to Marketo’s Design Studio, then changing the above URL to reflect your Marketo-hosted version.)
  2. Place this code snippet where you want the video to appear:<div id=”digitalpi-yt-player” data-youtube-id=”XXXXXXXXXX”></div>
  3. Change XXXXXXXXXX to your YouTube video ID, from the YouTube URL

Accessing video tracking info in Marketo

Okay, so the video is tracked. How can you, the savvy Marketo practitioner, access this information and use it in your marketing? There are several things you need to know.

  1. In Marketo, these YouTube video interactions are logged as click events.
  2. The page URL is always the same——regardless of which page the request originated on.
  3. This tracking works even on anonymous leads–before they submit their name or email address.

Here is how the video interactions show up as lead activities.

Activity Details for Click Link entry in test lead's Activity Log Activity Details for Click Link entry in test lead’s Activity Log

In a smart list, you could use a filter for all leads that reached the 25-percent-watched milestone.

Marketo filter for tracked YouTube video interaction Marketo filter for tracked YouTube video interaction

Or you could use the same parameters in a trigger.

Marketo trigger for tracked YouTube video interaction Marketo trigger for tracked YouTube video interaction

Finally, to trigger a status change or scoring increase when a lead finishes watching a video, you can search for a query string containing movie-action=played-to-end.

Marketo trigger for YouTube video viewed to end Marketo trigger for YouTube video viewed to end

Look at the demo video’s log above to get an idea of what parameters are available for your Marketo filters and triggers. Remember, you can use as much or as little of the query string to get as specific or general as you want depending on how much or how little of it you include. Here are some query strings from the example above and ideas on how you could possibly use them:

Query String Parameters Interpretation & Use Case
video=jdi-qqFv24A&movie-action=played-to-end Watched a specific video to the end. Use to set program status to Engaged or equivalent success step.
movie-action=played-to-end Watched any tracked YouTube video on your site to the end. Use to increase Behavior Score in your global scoring program. This may also be a good opportunity to log an Interesting Moment for Sales.
video=jdi-qqFv24A&movie-action=achieved-milestone&percent=50 Watched at least half of a specific video. Use to set program status to Interested or equivalent pre-success step. Possibly use to increase Behavior Score.
movie-action=achieved-milestone&percent=50 Watched at least half of any tracked YouTube video on your site. Use to increase Behavior Score.
movie-action=pressed-play&percent=0 Started watching any tracked YouTube video on your site. Use to increase Behavior Score.

Configure the YouTube tracking script and player settings

By default, this video player will log milestones when a known lead watches 25%, 50% or 75% of the video, but these can be changed to suit your needs.

In addition to Marketo tracking, this script also empowers you to overcome some of YouTube’s default embedded YouTube video player’s other limitations and settings:

  • The video player will scale responsively for tablet or mobile devices.
  • The player’s controls and video title are hidden by default.
  • “Related” videos will not display at the end of the video.

Any of these options can be changed in the script itself, including the percentages for the milestones.

Settings for YouTube videos tracked in Marketo Settings for YouTube videos tracked in Marketo

Have questions, suggestions for improvements or requests for specific features? Let us know in the comments below.

Jon Bourne is a marketer with a varied background in technology, design, agency consulting and direct sales. He has been a front-end developer, account executive, technology consultant, creative director, and head of marketing as well as an owner, partner and executive in multiple design and development agencies. Jon brings his technical background together with branding and marketing savvy to deliver return-oriented strategies that drive top-line growth and create efficiencies and cost savings for client companies—turning marketing organizations from cost centers to profit centers.

  • June 14, 2017

    This script works at the moment only on the first instance of an embedded video on the page. How can we make multiple embedded videos on a single page?

      • JD Nelson

        Leave reply
        June 16, 2017

        this would be a killer improvement — I anxiously await the new code. Nice work so far!

          • JD Nelson

            August 11, 2017

            I’m still using this code on more and more videos — it’s great. I’d love to be able to use it on a library of videos if the multiple video code were to magically arrive. 🙂
            Good stuff!!

          • JD Nelson

            August 30, 2018

            I just came back trying to figure out why 2 videos wouldn’t work — looks like I had forgotten about our previous conversation. Woe is me!

  • Brendan Gallagher

    Leave reply
    June 16, 2017

    I was not able to get this to work on a Marketo Guided Landing Page. Any suggestions of common issues? To be specific, the issue is that the embedded video does not display.

      • Brendan Gallagher

        Leave reply
        July 7, 2017

        Hi Jon,

        I believe I have figured out the issue and it has to do with Marketo’s WYSIWYG editor (technically I am adding it into the HTML/source area) adding a “nbsp;” in the blank div after I submit the code, which seems to throw it all off. I was able to get it to work fine (same exact code) on other sites and CMS’s where the editor does not automatically add in any breaks or nbsps. Very annoying, but it seems like the problem is Marketo and not your script, or my user error. Thanks!

  • JD Nelson

    Leave reply
    August 11, 2017

    I’m trying to differentiate lead sources on this code, but am struggling with the logic behind it.
    What I WANT to do is add a querystring to the ‘click link on page’ trigger so that one smart campaign fires with querystring ?abc and a different smart campaign triggers with querystring ?def — but I realized that the code itself is looking for a querystring to identify length of watched … how do I couple these together to allow both but not break either?

  • j Streeter

    Leave reply
    September 5, 2017

    Is there a way to create a lead from those who view a video on YouTube itself? Or can it only be an embedded video?

  • November 7, 2017

    Hi Jon,
    Wil the script also work for Vimeo?

  • February 20, 2018

    Hi Jon,

    Is that possible to make this script works for a non-Marketo landing page? Our current youtube video is embedded on our website but with the Muchinkin code.


  • Bill Jones

    Leave reply
    March 27, 2018

    Hi Jon!

    Have you had any issue with the video not showing up if Google Tag Manager code is also present on the page?