Connecting Tech Pros Worldwide Forums | Help | Site Map

ASP Help Please!

No Spam Please
Guest
 
Posts: n/a
#1: Jul 19 '05
I have a script. Its a login form that has the user enter their First Name,
Last Name and ID #. That data along with the currdate and currtime is
placed in an access database and the framed page loads. I would like to be
able to record in the database number of minutes spent on the page when they
exit the page. Any help will be greatly appreciated.

Thanks all.

Rich

Steve Lutz
Guest
 
Posts: n/a
#2: Jul 19 '05

re: ASP Help Please!


Some other ways besides Ray's session variables:

1) add a "LAST_ACCESS_TIME" column to the table. Each time the user views a
page, update the record with the current time. This way you will know the
start time of the users session, and the time that any page was last
accessed. (Subtract end from start and you get session length). This method
means a database hit on every page, so if you have high traffic on this
site, you may want to reconsider using access and use another database
server (SQL Server, Oracle, Postgres, etc).

2) Have a Javascript onpage.unload or window_onbeforeunload function that
changes the document location to a logoutpage. The logout page could update
the database with the session end time. Of course, you would need this on
each page, and you'd want to check where the user was going before hand so
you could then redirect them to the right place. I don't think this would
work if the user closes the window though. So, althought probably feasible,
this method would be a pain in the butt to get right. (Especially if you
want cross browser capability).

Lastly, if you are expecting to run the website in a server pool, the
Session object doesn't (easily) exist across multiple servers (.NET helps
this though).

Steve


"No Spam Please" <RJPoethig@aol.com> wrote in message
news:0Bqfb.30402$E95.9189551@news4.srv.hcvlny.cv.n et...[color=blue]
> I have a script. Its a login form that has the user enter their First[/color]
Name,[color=blue]
> Last Name and ID #. That data along with the currdate and currtime is
> placed in an access database and the framed page loads. I would like to[/color]
be[color=blue]
> able to record in the database number of minutes spent on the page when[/color]
they[color=blue]
> exit the page. Any help will be greatly appreciated.
>
> Thanks all.
>
> Rich[/color]


No Spam Please
Guest
 
Posts: n/a
#3: Jul 19 '05

re: ASP Help Please!


Let me explain more on what I am doing.

The login form takes the user to a webcast framed template. From that
template they have 9 videos listed. All videos are manditory viewing and we
need to verify that they had the page open (video is embedded on the page)
based on number of minutes on the page. I would like to track how much time
is spent on each video.

Structure looks like this:

Login.asp goes to:

clip1/wm_player_frameset.asp
from here the user can select 8 other videos which goes to

clip2/wm_player_frameset.asp
clip3/wm_player_frameset.asp
clip4/wm_player_frameset.asp
clip5/wm_player_frameset.asp
clip6/wm_player_frameset.asp
clip7/wm_player_frameset.asp
clip8/wm_player_frameset.asp
clip9/wm_player_frameset.asp

The database has fields called:

firstn
lastn
VZID
currDate
currTime
clip1
clip2
clip3
clip4
clip5
clip6
clip7
clip8
clip9

I would like to populate those fields (clip#) with the number of minutes
spent at each wm_player_frameset.asp page
I know I have to also pass at least the ID field value between pages.
I was able to find a script that assigns the number of minutes on the page
to a varable (see below). I can call that varable clip1, clip2, clip3... in
each wm_player_frameset.asp file but I don't know how to have the OnUnload
write the varable to the database.

<SCRIPT LANGUAGE="Javascript">

pageOpen = new Date();
function timeon() {
pageClose = new Date();
minutes = (pageClose.getMinutes() - pageOpen.getMinutes());
{
clip1 = (minutes);
}
}
// End -->
</SCRIPT>
</HEAD>

<BODY OnUnload="timeon()">

Thanks
Rich
Steve Lutz
Guest
 
Posts: n/a
#4: Jul 19 '05

re: ASP Help Please!


The problem you are going to have is knowing when the user exits the browser
or leaves the page that each video is on. When the user leaves the page, you
could redirect somewhere else to do that database recording, but when they
close the browser, this isn't possible. (I don't think) Since the window
onunload scripts are all client side also, the cannot hit the database
(unless you start putting direct client access to the database on the site,
which is something you probably don't want. ) So you have 2 problems,
recording the data you want to capture, and storing the data into the
database.

You could record the data in user cookies. So you could have a client side
javascript block like: (this is freehand coded.. probably has syntax errors
and such:

<SCRIPT>

var video_number = 1;
window.onload = function(e)
{
var now = new Date()
createCookie("Load" + video_number,now.GetTime(),365);
}

window.onunload = function(e)
{
var now = new Date()
createCookie("Unload" + video_number,now.GetTime(),365);
}

function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
</SCRIPT>

This coded will save the data.

When the next video loads, you could then check all the user's cookies to
audit them:

<%

For x = 1 to Request.Cookies.Count
if instr(Request.Cookies.Key(x),"Load") > 0 then
videoNum = cLng(replace(request.cookies.Ken(x),"Load","")
unloadTime = cDate(request.Cookies(request.cookies.key(x))
' Store this in database
else if
instr(Request.Cookies.Key(x),"Unload") > 0 then
videoNum = cLng(replace(request.cookies.Ken(x),"Unload","")
loadTime = cDate(request.Cookies(request.cookies.key(x))
' Store this in database
end if
end if
next
%>

You could also force users to an audit page that will record all the cookies
to the database and then let them know if they "passed" or not.

Hope this helps, it's early in the morning, so I'm sure my code needs a lot
of work, but I hope you get the idea.

Steve



"No Spam Please" <RJPoethig@aol.com> wrote in message
news:gjsfb.31332$E95.9778639@news4.srv.hcvlny.cv.n et...[color=blue]
> Let me explain more on what I am doing.
>
> The login form takes the user to a webcast framed template. From that
> template they have 9 videos listed. All videos are manditory viewing and[/color]
we[color=blue]
> need to verify that they had the page open (video is embedded on the page)
> based on number of minutes on the page. I would like to track how much[/color]
time[color=blue]
> is spent on each video.
>
> Structure looks like this:
>
> Login.asp goes to:
>
> clip1/wm_player_frameset.asp
> from here the user can select 8 other videos which goes to
>
> clip2/wm_player_frameset.asp
> clip3/wm_player_frameset.asp
> clip4/wm_player_frameset.asp
> clip5/wm_player_frameset.asp
> clip6/wm_player_frameset.asp
> clip7/wm_player_frameset.asp
> clip8/wm_player_frameset.asp
> clip9/wm_player_frameset.asp
>
> The database has fields called:
>
> firstn
> lastn
> VZID
> currDate
> currTime
> clip1
> clip2
> clip3
> clip4
> clip5
> clip6
> clip7
> clip8
> clip9
>
> I would like to populate those fields (clip#) with the number of minutes
> spent at each wm_player_frameset.asp page
> I know I have to also pass at least the ID field value between pages.
> I was able to find a script that assigns the number of minutes on the page
> to a varable (see below). I can call that varable clip1, clip2, clip3...[/color]
in[color=blue]
> each wm_player_frameset.asp file but I don't know how to have the OnUnload
> write the varable to the database.
>
> <SCRIPT LANGUAGE="Javascript">
>
> pageOpen = new Date();
> function timeon() {
> pageClose = new Date();
> minutes = (pageClose.getMinutes() - pageOpen.getMinutes());
> {
> clip1 = (minutes);
> }
> }
> // End -->
> </SCRIPT>
> </HEAD>
>
> <BODY OnUnload="timeon()">
>
> Thanks
> Rich[/color]


Closed Thread