CANDDi can track Youtube videos to record everyone who has started, paused, or completed watching a video. This requires custom javascript to be added on to each page with a video on it. Here are two pages you should read to make this work:

https://developers.google.com/youtube/js_api_reference

https://developers.google.com/youtube/youtube_player_demo

Here’s how to track YouTube. This tutorial assumes you have jQuery on your site.

Get the dom element which contains the YouTube video. If the video code looks like this:
<iframe id="ytplayer" type="text/html" src="//www.youtube.com/embed/M7lc1UVf-VE" frameborder="0" allowfullscreen> then add an event listener for the ‘onstatechange’ event and trigger events to CANDDi.

$( document ).ready(function() {
$("#ytplayer").addEventListener(
"onStateChange",
function(newState) {
if(window.canddi) {
window.canddi.sendEvent(
'video/[VideoName]/'+newState,
{},
false,
"Video"
);
});

});

NOTE: Replace [VideoName] with a unique identifier for this video, Replace start with the action you wish to track (start / stop / pause etc...)

Have more questions? Contact us at hello@canddi.com or 0161 414 1080
Was this article helpful?
Cancel
Thank you!