Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

Time Spent in Form

Avatar

Level 7

I would like to track the following: a timestamp when the user first opens a form, and the total time spent filling out a form. Is it possible to collect this information?

1 Accepted Solution

Avatar

Correct answer by
Level 8

You could store the time when the user opens the form and store it again when the user saves the form and show the difference.

Here's how you can do it:

1) Create a hidden field called startTime and put this JavaScript in the docReady event of the field:

this.rawValue=(new Date()).getTime();

2) Create another hidden field called endTime and put the following JavaScript in the preSave event of the field:

this.rawValue=(new Date()).getTime();

var dif = this.rawValue-startTime.rawValue;

var d = new Date(dif);

totalTime.rawValue="Hours: "+d.getUTCHours()+" Minutes:"+d.getMinutes()+" Seconds:"+d.getSeconds();

3) Create a third field called totalTime.

Kyle

View solution in original post

1 Reply

Avatar

Correct answer by
Level 8

You could store the time when the user opens the form and store it again when the user saves the form and show the difference.

Here's how you can do it:

1) Create a hidden field called startTime and put this JavaScript in the docReady event of the field:

this.rawValue=(new Date()).getTime();

2) Create another hidden field called endTime and put the following JavaScript in the preSave event of the field:

this.rawValue=(new Date()).getTime();

var dif = this.rawValue-startTime.rawValue;

var d = new Date(dif);

totalTime.rawValue="Hours: "+d.getUTCHours()+" Minutes:"+d.getMinutes()+" Seconds:"+d.getSeconds();

3) Create a third field called totalTime.

Kyle