Skip to content

Instantly share code, notes, and snippets.

@kaitwalla
Last active August 29, 2015 13:59
Show Gist options
  • Save kaitwalla/10747182 to your computer and use it in GitHub Desktop.
Save kaitwalla/10747182 to your computer and use it in GitHub Desktop.
VideoJS — Progress update tracking
_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