Need a little course in ASP

  • Hi there,

    I know there are many web developers out there, so I need a little push into the right direction on this.

    I know how to track page impressions into a db.

    But how can I determine how long a visitors stays on a side?

    And bear with me, if this a simple question

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Easiest way: Set a cookie containing the time when the page finishes loading.

    On the next page (or same one) attemp to retrieve the cookie and get the time. Start - new start = (you get the idea) 🙂

    Your only problem will be the last page the persons sees. You can "fix" this problem by using session.timeout and update the value in the DB.

    Cheers,

    Crispin

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • Hi Crispin,

    quote:


    Easiest way: Set a cookie containing the time when the page finishes loading.

    On the next page (or same one) attemp to retrieve the cookie and get the time. Start - new start = (you get the idea) 🙂

    Your only problem will be the last page the persons sees. You can "fix" this problem by using session.timeout and update the value in the DB.


    although I understand the idea, I must admit I haven't dealt with say 'advanced asp' yet.

    I've figured out I get access to cookies via Request.Cookies. Can you post any working example on cookies?

    Cheers,

    Frank

    Edited by - a5xo3z1 on 07/14/2003 06:46:54 AM

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • hmmm. Does ASP get advanced?

    <%

    Response.Cookies("Test") = "FFF" Sets it.

    Response.Write "|" & Request.Cookies("Test") & "|" Gets it back

    %>

    Cheers,

    Crispin

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • quote:


    hmmm. Does ASP get advanced?


    Version 3.0 is even in M$ dimensions somewhat advanced or matured

    quote:


    <%

    Response.Cookies("Test") = "FFF" Sets it.

    Response.Write "|" & Request.Cookies("Test") & "|" Gets it back

    %>


    simple as that.

    Thanks!

    Now, is this practical for websites (frequently used)or is there another to keep track of visitors and page impressions?

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Have you considered working this out from your webserver logs? If your webserver is IIS, I seem to remember its just a few clicks to import your webserver logs straight into SQL Server. Write a few queries and off you go ...

  • Hi planet115,

    quote:


    Have you considered working this out from your webserver logs? If your webserver is IIS, I seem to remember its just a few clicks to import your webserver logs straight into SQL Server. Write a few queries and off you go ...


    I have, but I'm not admin of the webserver and can not get hands on it. so I have to do this myself

    Cheers,

    Frank

    Edited by - a5xo3z1 on 07/14/2003 07:15:53 AM

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • This is a method I have used before and heard of others using it with no draw backs. The only disadvantage is that youo have a DB query every page but it's a small query so unless you planning on adding this to CNN's front page, you should be ok.

    planet115's idea is not bad. Maybe you could have a johb to import the data every night and run reports.

    Cheers,

    Crispin

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • quote:


    I'm not admin of the webserver and can not get hands on [the logfile] . so I have to do this myself


    Can't think of any general reason why you shouldn't get access to this -- there may be a specific reason of course.

    If all you want to do is find out how long the user stays on each page then Crappy's method is fine -- although if you don't already have a global include it's obviously a pain to add code to every page -- but if your client is going to come back tomorrow and say "I'ld really like stats on the most popular page/click depth/blad de blah" then the webserver logfile is really the way to go and you might as well insist on getting access to the file now before you waste time going off in another direction .... just my 1/50 dollar 🙂

  • Frank,

    If you don't have access to it and _really_ want to get the files, you could change the log path it be withint the site and read it via HTTP.

    Cheers,

    Crispin

    Something as incredibly simple as

    binary still gives you too many options

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • quote:


    If all you want to do is find out how long the user stays on each page then Crappy's method is fine -- although if you don't already have a global include it's obviously a pain to add code to every page -- but if your client is going to come back tomorrow and say "I'ld really like stats on the most popular page/click depth/blad de blah" then the webserver logfile is really the way to go and you might as well insist on getting access to the file now before you waste time going off in another direction .... just my 1/50 dollar 🙂


    no client involved. It's just for internal reasons, basically for me to see who is on my department site. So Crispin's solution is fine. I hope it isn't too much work to encapsulate it and call at first and last command on every page.

    Is this correct, Crispin?

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Crispin, that's very naughty

    Oh, and I think you just need to log the time as the last command of every ASP page. (trapping between the first and last commands just tells you how long the asp code took to execute). I think what Crispin means is you deduce the time spent on the previous page like this.

    1) Execute usual ASP page commands

    2) Retrieve cookie value of [LASTACCESS]

    3) If [LASTACCESS] is set then:

    Update your DB to show the time spent on the last page (HTTP-REFERRER) as [NOW]-[LASTACCESS]

    4) Set the [LASTACCESS] cookie value to now

    remember to set the LASTACCESS cookie to expire within a reasonable time period ...

    Edited by - planet115 on 07/14/2003 07:57:57 AM

  • quote:


    Crispin, that's very naughty


    What I do?

    Frank, the easiest way would bee to have a file and include it in every page.

    <!-- #INCLUDE VIRTUAL="Path From root/xxx.asp"--> OR

    <!-- #INCLUDE FILE="../../../xxx.asp"-->

    This file would first check the last visited time then reset the cookie to the new time.

    Cheers,

    Crispin

    Something as incredibly simple as

    binary still gives you too many options

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • quote:


    Crispin, that's very naughty

    Oh, and I think you just need to log the time as the last command of every ASP page. (trapping between the first and last commands just tells you how long the asp code took to execute). I think what Crispin means is you deduce the time spent on the previous page like this.

    1) Execute usual ASP page commands

    2) Retrieve cookie value of [LASTACCESS]

    3) If [LASTACCESS] is set then:

    Update your DB to show the time spent on the last page (HTTP-REFERRER) as [NOW]-[LASTACCESS]

    4) Set the [LASTACCESS] cookie value to now

    remember to set the LASTACCESS cookie to expire within a reasonable time period ...


    please tell me more about redirecting logs

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

Viewing 15 posts - 1 through 15 (of 20 total)

You must be logged in to reply to this topic. Login to reply