Skip to content
Closed

Time #1757

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Form Timer – ServiceNow UX Tracker

Track how long users spend on a form before submitting it. Useful for UX analysis, training feedback, or identifying complex forms.

## 💡 Features

- Tracks time spent on form in seconds
- Displays message on submission

## 🛠 Setup

1. Add one Display BR and a Client Scripts:
- `displayBR`: Starts timer
- onLoad client script: set the start time
- `onSubmit client script: Calculates and stores time
2. create a field u_spent_time to store the start time

## 🤝 Contributing

Ideas for improvement:
- Track time per section/tab
- Send data to analytics dashboard
- Visualize average time per user/form
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
g_scratchpad.startTime= new GlideDateTime(); // store the start the time on Display BR using
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
g_form.setValue('u_start_time',g_scratchpad.startTime); // set the hidden field value via onLoad client script by getting the value via scratchpad
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// onSubmit Client Script

var formEndTime = new Date().getTime(); //get the current time
var timeSpentMs = formEndTime - g_form.getValue('u_spent_time'); //get the duration of time spent
var timeSpentSec = Math.floor(timeSpentMs / 1000);

g_form.addInfoMessage("You spent " + timeSpentSec + " seconds on this form."); // show the info or we can do multiple things related to reporting
return true;
Loading