Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

track HTML5 Video percentages #3

Open
eduardocereto opened this issue Feb 3, 2012 · 3 comments
Open

track HTML5 Video percentages #3

eduardocereto opened this issue Feb 3, 2012 · 3 comments
Labels

Comments

@eduardocereto
Copy link
Contributor

Just like we do for Youtube

@phms
Copy link

phms commented Feb 22, 2012

Digital Cube's team is working to correct this error.

@ghost ghost assigned phms Feb 22, 2012
@brodseba
Copy link

$('audio,video').bind('timeupdate', function(e) {
  var percentPlay = 1;
  var percentStr = "";
  var videosStateID = "";
  var videosLogStr = [];

  percentPlay= this.currentTime / this.duration * 100;
  if (percentPlay >= 99) {
      percentStr = "end";
  }
  else if (percentPlay >= 75) {
      percentStr = "75%";
  }
  else if (percentPlay >= 50) {
      percentStr = "50%";
  }
  else if (percentPlay >= 25) {
      percentStr = "25%";
  }
  else {
      percentStr = "start";
  }

  videosStateID = this.currentSrc + percentStr;

  if (videosLogStr.indexOf(videosStateID) == -1) {
    _gaq.push(['_trackEvent', 'Video', this.currentSrc, percentStr]);
    videosLogStr = videosLogStr + videosStateID;
  }
});

@tomfuertes
Copy link
Contributor

Code above looks great! Feel free to reopen a PR with no jQuery dependency and get it into core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants