Keep track of total elapsed time that modal is open & store in downloaded data-set | XM Community
Skip to main content
I wish to record the total elapsed time that a modal is open for

e.g. https://www.qualtrics.com/community/discussion/comment/11155#Comment_11155



Each time it is opened, elapsed time should be added to total_elapsed and a variable for count should be incremented



Each time total_elapsed is incremented with elapsed time, or at the point at which the user enters the next stage of the survey, total_elapsed and count should be stored



This data - the name of the modal/iframe along with total_elapsed and count - should be stored such that it's displayed in the downloaded data-set



It would be even better if it were possible to store each time elapsed measurement together with total_elapsed and count



Many thanks

Emir
Can you put your modal into its own block and add a timing question to the block. If your survey is in blocks, each block can have its own timing question.
> @WaterSampler said:

> Can you put your modal into its own block and add a timing question to the block. If your survey is in blocks, each block can have its own timing question.



Understood, and it is, but I want to keep track of how long each modal is open, not just how long the user is in the block.

Thanks for your input.
Emir,



You will probably have to do some experimenting with JS. Try creating a button to start the sequence. Then get the time, open the link in a new tab, get the time when returning after the tab is closed. The button is used to group the three commands together.
> @WaterSampler said:

> Emir,

>

> You will probably have to do some experimenting with JS. Try creating a button to start the sequence. Then get the time, open the link in a new tab, get the time when returning after the tab is closed. The button is used to group the three commands together.



Again, understood. And in fact I anticipate that the modal will pop up within the window (not in a new tab). (Note that I do follow your logic, though.)



This does not answer the key questions of how to store custom data within the environment and such that it is accessible from the downloaded dataset.
To store the data, create a question to hold the time, probably a number to hold the number of seconds. Hide the question from the user and use the JS to put the value into the question.
> @WaterSampler said:

> To store the data, create a question to hold the time, probably a number to hold the number of seconds. Hide the question from the user and use the JS to put the value into the question.



Thanks for your further input. Are you able to provide an example of this?
For the hidden variable, put

this.getQuestionContainer().hide();

into the Qualtrics.SurveyEngine.addOnload area.

alert(this.questionId); // debug to get the question ID nnn for below



In your button processing routine add

var TimedView = "$(q://QR~QIDnnn)"; // where nnn is the number of the above hidden question

TimedView.value = EndTime - StartTime;
> @WaterSampler said:

> For the hidden variable, put

> this.getQuestionContainer().hide();

> into the Qualtrics.SurveyEngine.addOnload area.

> alert(this.questionId); // debug to get the question ID nnn for below

>

> In your button processing routine add

> var TimedView = "$(q://QR~QIDnnn)"; // where nnn is the number of the above hidden question

> TimedView.value = EndTime - StartTime;

>

>



Appreciate the snippet. Will have a go and report back soon.

Leave a Reply