Javascript for time stamp | XM Community
Skip to main content
Solved

Javascript for time stamp

  • October 21, 2018
  • 4 replies
  • 127 views

Hi, I'm starting a survey with 3 videos and I need the time the participant pressed 'play'. All I managed to figure out is how to record the timestamp of the onload. Any Ideas? Thanks!

Best answer by Anonymous

> @TomG said: > @avigail_24 - I believe you'll need to make one change to @Shashi's code. I think `${date://CurrentDate/c}` is the same as load time because it is resolved on the server before the page is sent to the browser. Use something like `s = new Date();` instead. Thanks @TomG for the correction

4 replies

  • October 21, 2018
Hello @avigail_24 , Assuming you have three question which contains one video each on separate page using HTML5 video tag. Step 1: Create an embedded data(Vid1PlayTime, Vid2PlayTime, Vid3PlayTime) in the survey flow before video questions. Step 2: Paste the following code in the js(onReady) of your first video question var s=''; jQuery("video").on('play', function() { if(s==''){ s= new Date(); Qualtrics.SurveyEngine.setEmbeddedData( 'Vid1PlayTime', s); } }); Step 3: The above code will set "Vid1PlayTime" embedded data with timestamp of first video. Similarly paste the above code in other two questions with changing the embedded data variable i.e Vid2PlayTime for Q2 and Vid3PlayTime for Q3

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • October 21, 2018
@avigail_24 - I believe you'll need to make one change to @Shashi's code. I think `${date://CurrentDate/c}` is the same as load time because it is resolved on the server before the page is sent to the browser. Use something like `s = new Date();` instead.

  • Answer
  • October 22, 2018
> @TomG said: > @avigail_24 - I believe you'll need to make one change to @Shashi's code. I think `${date://CurrentDate/c}` is the same as load time because it is resolved on the server before the page is sent to the browser. Use something like `s = new Date();` instead. Thanks @TomG for the correction

  • Author
  • October 22, 2018
Thank you!! That was so helpful (and worked!)