Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

record duration of visit

Status
Not open for further replies.

newbiepg

Programmer
Nov 6, 2002
181
IN
I need to know when a user closes the browser or exits our site after visiting it.

Is there a way to record this time , even approximately?

 
There are a couple of ways to do this.

1.
You can use Session_OnStart and Session_OnEnd in the Global.asa file:

Session_OnStart will be executed when the user first arrives at the site

Session_OnEnd will be executed when the user leaves the site

In the global.asa file add the following:

<SCRIPT LANGUAGE='VBScript' RUNAT='Server'>
Sub Session_OnStart
**Put your code here that records the time the user enters the site to a database**
End Sub

Sub Session_OnEnd**Put your code here that records the time the user leaves the site to a database**
End Sub
</SCRIPT>


2.
A lot less elegant way is when users log in and out to record the times. I will not advise this, as there are a lot of issues using this method, and users have to log in and out which is maybe not your case.
 
my problem with Session_OnEnd is that nothing in there gets executed
the start time in Session_OnStart works fine
 
Please provide code for OnEnd so that I can have a look at it
 
Session_OnEnd is known for it's unreliability.

How about if you use some javascript on your pages, to open a popunder window &quot;onUnload&quot;, the popunder window, can update the time that this user left, then close itself. If you do it on every page, then the last page he/she visits of yours would be recorded.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top