Last active
August 29, 2015 13:59
-
-
Save kaitwalla/10747182 to your computer and use it in GitHub Desktop.
VideoJS — Progress update tracking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_V_(document.getElementById('player'),{},function() { | |
var videoID = this.id(); | |
window[videoID] = {}; | |
window[videoID].pct = 1; | |
var trackEvent = function() { | |
var videoID = this.id(); | |
_gaq.push(['_trackEvent', 'VideoJS', event.type,videoID]); | |
}; | |
var trackTime = function() { | |
var videoID = this.id(); | |
wv = window[videoID]; | |
wv.curr = this().currentTime(); | |
if (wv.curr/wv.pct >= wv.pct*.1 && wv.pct != 10) { | |
_gaq.push(['_trackEvent', 'Progress', String(wv.pct)+'0%',videoID]); | |
wv.pct++; | |
} | |
_gaq.push(['_trackEvent', 'VideoJS', event.type,videoID]); | |
}; | |
this.on('play',trackEvent); | |
this.on('timeupdate',trackTime); | |
this.on('ended',trackEvent); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment