Does anyone know of a way to save to capture and save the amount of time spent on a page in ASP.NET MVC?
Edit To clarify a few points:
- Essentially the system is concerned with product placement. I am tracking the # of views of a particular product. However, to take it further I would like to see on average how long customers stay on a particular product page
- I would like to save and store the data locally so that I can trend and analyze it along with other data currently captured - i'd like to avoid external services wherever possible.
- My main concern is with trapping an event on page load and again on exit - this is obviously difficult a) because ASP.NET MVC doesn't have as rich/fancy an event pipeline as vanilla ASP.NET and b) it is possible that a user will close the browser/navigate to a different site thereby complicating matters a little.
Thanks in advance, JP
Using a .NET MVC Controller Action as the Source for an HTML <img>
1:ASP.NET MVC: How do I validate a model wrapped in a ViewModel?
I guess you could have an ajax function this calls home every x seconds or minutes with a small package just the sessionId and page/url, on the server side it would know to add x time to the proper structure structure. . Ananother way could be to have a hidden field this has the creation time stamp of the page, and then intercept the page is changed/closed/nav. away, and then call home with the time difference (or the 2 values and did the calc server side) and the the page/url... although I think you could risk not receive ting the info if the browsers suddenly crashes, or the call is lost and the page already changed.. just any suggestions.