Forum Moderators: open
There's probably a better way, but for sure some variant of this would work.
PebĪ
I thought of something similar to this, but we run into the problem because the client does not want to record the amount of time on every page, only specific pages.
Also, there doesn't seem to be a way to capture the time on a page if the user closes his or her browser or leaves the site correct?
You are exactly right! That will allow me to apply it to only the pages I need to track too. The only event this would not account for then is if someone closed their browser while looking at a page I'm tracking... correct?
Thanks to everyone for all the great replies! Your time and thoughts are much appreciated.
I am able to get the onUnload event to call an asp page in which I capture the end time for my previous page view. This works great. My question now is, how do I know why the user left the page so that I may redirect them appropriately?
I have done some research on this, but cannot seem to find a way to capture the event that occurred. If they clicked a link, what link did they click? If they typed in a new url, what url did they type in?
Currently, when they leave the page for any reason, they get sent to my asp page that records the endTime, but then they just sit there... (I don't know where to redirect them)
Thanks.
Currently, when they leave the page for any reason, they get sent to my asp page that records the endTime, but then they just sit there... (I don't know where to redirect them)
Instead of actually sending the user to your asp page, couldn't you have the onunload function call your endTime recorder page in the background, either by loading it as an image, or with a background http (ajax) call to that page. Not sure if it would work but worth a try.