function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
thinkjerrythinkjerry 

Logging session duration for users

I need to identify how long specific users are logged into salesforce.com for. Currently, I just can see date/time stamps of when they modify records and when the login, but not time spent while logged in. This information is important to my business. How can his be done?

Best Answer chosen by Admin (Salesforce Developers) 
sh-at-youseesh-at-yousee

Hi,

 

In short. It cannot be done.

 

The reason for this is that you have no control over how your users close the application. In theory, you could create a custom logout button which saves a timestamp indicating when the user logged out but 90% of your end-users will forget that and simply close the browser. It's a well-known issue for all web applications.

 

We also would like to measure how long our CSRs work on any given case. For that we've created a custom object containing a timestamp which is created whenever a user takes ownership of a case and whenever the ownership is pushed back into a queue. The difference between the two timestamps then gives us an idea of how long time a given CSR worked on that case. However, then you run into issues like business hours etc. (imagine a user takes ownership of a case Friday and then leaves for the weekend and not until Monday push the case back into a queue).

 

Anyway, I've never come across a good solution for this problem in any web application. I've tried to implement something similar in a previous job and again, we could only come up with an estimate because, in the end, your users can simply close the browser.

 

What we did back then was we continuously sent ping requests back from the client application to the server and logged it to a unique session id. Then we simply agreed that the last ping subtracted from the first ping (login) would give us the time spent in the application. With that solution you also face the issue of how often to send these ping requests (performance vs. correct statistics).

 

I hope this has shed some light on the issue and I wish you good luck in your hunt for a good solution.

 

Cheers.

 

Søren Nødskov Hansen