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

Javascript for time stamp

  • Oct 21, 2018 5:56 AM UTC
  • 4 replies
  • 161 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
View original

4 replies

  • Oct 21, 2018 1:26 PM UTC
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 ●●●●●●●●
  • Oct 21, 2018 8:33 PM UTC
@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
  • Oct 22, 2018 5:48 AM UTC
> @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
  • Oct 22, 2018 11:17 AM UTC
Thank you!! That was so helpful (and worked!)