ASP.NET MVC - Determining Time Spent on a Page
Does anyone know a way to save to capture and save time spent per page in ASP.NET MVC?
Edit . To clarify a few points:
- Essentially, the system is about product placement. I am tracking #views for a specific product. However, to take this further, I would like to see, on average, how long customers stay on a specific product page.
- I would like to store and store the data locally so that I can track and analyze it along with the other data that is currently being captured - I would like to avoid external services where possible.
- My main concern is to capture the event on page load and again on exit - this is obviously tricky;) since ASP.NET MVC doesn't have such a rich / fancy event pipeline as vanilla ASP.NET, and b) it it is possible that the user will close the browser / go to another site, thereby complicating the situation a little.
Thanks in advance, In JP
a source to share
It depends, you can use javascript to track the time and display it on the page.
If needed on the server and on the form that posts the posts, you can put the time in a hidden field, and then in the post, you can extract the value and calculate the difference.
You can try storing it in a cookie. Every time a user requests a new page, you can retrieve the page title and timestamp and then set a cookie with the new page and timestamp.
You can also use some kind of Business Intelligence suite. For example Omniture or Google Analytics
a source to share
I guess you could have an ajax function that calls home every x seconds or minutes with a small batch of only sessionId and page / url, on the server side it would know to add x times to the correct struct structure.
Another way could be to have a hidden field with the page creation timestamp and then intercept the page with change / close / navigation. and then call home with the time difference (or two values and from the calc server side) and the page / url ... but I guess you might not get the information if the browsers suddenly crash, or the call and the page has already changed.
just some suggestions
a source to share