I've been trying to use a Javascript to track the plays and pauses of a Youtube video as shown below but have realized that this was for videos from the Qualtrics library. Is there a way to replicate this with an embedded video?
Qualtrics.SurveyEngine.addOnReady(function()
{
pauseTimestamp = null;
playTimestamp = null;
pauses = [];
plays = [];
playCount = 0;
pauseCount = 0;
jQuery("video").on('play', function() {
playCount++;
playTimestamp = Date.now();
if (pauseTimestamp) {
pauses.push(playTimestamp - pauseTimestamp);
}
Qualtrics.SurveyEngine.setEmbeddedData('playCount', playCount);
Qualtrics.SurveyEngine.setEmbeddedData('pauses', pauses.join(";"));
});
jQuery("video").on('pause', function() {
pauseCount++;
pauseTimestamp = Date.now();
plays.push(pauseTimestamp - playTimestamp);
Qualtrics.SurveyEngine.setEmbeddedData('pauseCount', pauseCount);
Qualtrics.SurveyEngine.setEmbeddedData('plays', plays.join(";"));
});
var s='';
jQuery("video").on('play', function() {
if(s==''){
s= Date.now();
Qualtrics.SurveyEngine.setEmbeddedData( 'Vid1Start', s);
}
});
var z='';
jQuery("video").on('pause', function() {
if(z==''){
z= Date.now();
Qualtrics.SurveyEngine.setEmbeddedData( 'Vid1Pause', z);
}
});
});
Qualtrics.SurveyEngine.addOnUnload(function()
{
if (playCount > pauseCount) {
plays.push(Date.now() - playTimestamp);
Qualtrics.SurveyEngine.setEmbeddedData('plays', plays.join(";"));
} else if (pauseCount) {
pauses.push(Date.now() - pauseTimestamp);
Qualtrics.SurveyEngine.setEmbeddedData('pauses', pauses.join(";"));
}
});
Question on Tracking Pauses on Embedded Youtube Video
Sign up
Already have an account? Login
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login to the Community
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
