How to record date/time that a question was completed? | XM Community
Skip to main content
Solved

How to record date/time that a question was completed?


Forum|alt.badge.img+1

Hi, I have a survey that users are intended to access over a course of several months before submitting it. I want to track within the survey the date/time certain pages in the survey were viewed. I tried this Java script on an item, and also added a “DateMod1” embedded variable to the top of the survey:

 

Qualtrics.SurveyEngine.addOnLoad(function()
{/*Place your JavaScript here to run when the page is fully displayed*/
    var curDate = "${date://CurrentDate/m%2Fd%2FY}";
    Qualtrics.SurveyEngine.setEmbeddedData('DateMod1', curDate);
});

 

The embedded variable stays blank though even after passing that item/page. How do I fix this?

Best answer by Crystal250

Hi,

Just in case you (or someone else) has the same issue… I was looking to do a similar thing. I want to save the date/time at certain points in the survey to check its timing (the timing question has too many variables associated with it).

I did this:

  • Create the embedded variable in the survey flow, but give it a value. I also made it a text field because I thought that would work best. I gave mine the value “test value”
  • I also made sure the date in Javascript was saved as a string:

Qualtrics.SurveyEngine.addOnPageSubmit(function(type)
{
    var curDate = new Date().toString();
    console.log(curDate);
    Qualtrics.SurveyEngine.setEmbeddedData('completed_block_3', curDate);
});

This worked - I added a block to end the survey after my question, stepped through Preview and then checked the Data. I used the elipsis to view the results of my entry and could see the Embedded Data at the bottom.

I didn’t check setting the variable in a different function. I did try with a blank (no value set) value in complete_block_3 in the Survey Flow but that didn’t work.

Good luck!

View original

3 replies

vgayraud
QPN Level 5 ●●●●●
Forum|alt.badge.img+48
  • QPN Level 5 ●●●●●
  • 369 replies
  • July 12, 2024

Are you using the simple layout?


Forum|alt.badge.img+1
  • Author
  • Level 1 ●
  • 1 reply
  • July 12, 2024
vgayraud wrote:

Are you using the simple layout?

No, its the classic layout.


Forum|alt.badge.img+4
  • 6 replies
  • Answer
  • January 31, 2025

Hi,

Just in case you (or someone else) has the same issue… I was looking to do a similar thing. I want to save the date/time at certain points in the survey to check its timing (the timing question has too many variables associated with it).

I did this:

  • Create the embedded variable in the survey flow, but give it a value. I also made it a text field because I thought that would work best. I gave mine the value “test value”
  • I also made sure the date in Javascript was saved as a string:

Qualtrics.SurveyEngine.addOnPageSubmit(function(type)
{
    var curDate = new Date().toString();
    console.log(curDate);
    Qualtrics.SurveyEngine.setEmbeddedData('completed_block_3', curDate);
});

This worked - I added a block to end the survey after my question, stepped through Preview and then checked the Data. I used the elipsis to view the results of my entry and could see the Embedded Data at the bottom.

I didn’t check setting the variable in a different function. I did try with a blank (no value set) value in complete_block_3 in the Survey Flow but that didn’t work.

Good luck!


Leave a Reply