HTML5 video tracking
HTML
<div style="display: block; position: relative; max-width: 760px;">
<div style="display: block; padding-top: 56.5789473684211%;">
<video id="myHtml5PlayerID" preload="metadata" data-account="3262544219001" data-video-id="4443625177001" data-setup='{"techOrder": ["html5", "hls", "flash"]}' data-player="f9f89423-7975-4ba7-b926-811a4b2a543c" data-embed="default" class="video-js" controls="" style="width: 100%; height: 100%; position: absolute; top: 0px; bottom: 0px; right: 0px; left: 0px;"></video>
<script src="//players.brightcove.net/3262544219001/f9f89423-7975-4ba7-b926-811a4b2a543c_default/index.min.js"></script>
<script> $(".vjs-big-play-button").hide();
$(".vjs-play-control").hide();
</script>
</div>
</div>
JavaScript
//HTML5 default video tracking
videojs("myHtml5PlayerID").ready(function () {
var player, videoID, videoName, timeViewed, videoDuration, totalSeconds;
loadData();
function loadData() {
player = videojs('myHtml5PlayerID');
}
player.on("loadstart", function (evt) {
if (player.mediainfo) {
videoName = player.mediainfo.name;
console.log("videoName: " + videoName);
}
});
player.on("loadedmetadata", function () {
$(".vjs-big-play-button").show();
$(".vjs-play-control").show();
});
player.on("ended", function () {
logEvent("ended", player.currentTime());
alert("ended at: " + player.currentTime());
});
player.on("pause", function () {
alert("paused at: " + player.currentTime());
});
player.on("seeked", function () {
//logEvent("seeked", player.currentTime());
player.play();
});
player.on("progress", function () {});
player.on("timeupdate", function () {
//logEvent("timeupdate",player.currentTime());
console.log("timeupdate: " + player.currentTime());
});
player.on("durationchange", function () {
//logEvent("durationchange", player.currentTime());
});
player.on("abort", function () {
player.pause();
//logEvent("abort", player.currentTime());
});
player.one("play", function (evt) {
player.play();
alert("Started at: " + player.currentTime());
$(".vjs-big-play-button").hide();
console.log("play", player.currentTime());
});
function logEvent(eventName, timeViewed, totalSeconds) {
var lengthOfVideo = player.duration();
lengthOfVideo = (lengthOfVideo > 60 ? lengthOfVideo / 60 : lengthOfVideo);
lengthOfVideo = Math.round(lengthOfVideo * 100) / 100;
var duration = lengthOfVideo.toString().replace('.', ':');
var seconds = totalSeconds...