Capture Video Play | XM Community
Skip to main content
Question

Capture Video Play


Forum|alt.badge.img+3

Hello, 

 

I am trying to capture when participants play an embedded video. This is the script I’m using: 

 

Qualtrics.SurveyEngine.addOnload(function() {
  var video = document.getElementById('videoID);
  var playCount = 0;

  // Listen for the 'play' event of the video
  video.addEventListener('play', function() {
    // Increment playCount each time the video starts playing
    playCount++;
   
    // Update embedded data field with the current playCount
    Qualtrics.SurveyEngine.setEmbeddedData('EmbeddedVariableName', playCount);
    console.log('Video started playing. Play count: ' + playCount);
  });
  });

 

I’ve put the ID in the HTML and I have the embedded variable placed before the block with the video but it is still not working. Can anyone see an issue with my code? 

 

Thank you very much! 

Leave a Reply