how can I count the number of seconds a page is viewed?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • NotGiven

    how can I count the number of seconds a page is viewed?

    I am guessing I would hold a variable of when it's opened, then in the
    script that runs when the page is offloaded, I coudl calcualte it.

    How do you store a time variable?

    How do you calculate the amount of time (seconds) based on two timestamps?

    Thanks for your help and/or links to articles on the subject!


  • Disco Octopus

    #2
    Re: how can I count the number of seconds a page is viewed?

    NotGiven wrote:[color=blue]
    > I am guessing I would hold a variable of when it's opened, then in the
    > script that runs when the page is offloaded, I coudl calcualte it.
    >
    > How do you store a time variable?
    >
    > How do you calculate the amount of time (seconds) based on two
    > timestamps?
    >
    > Thanks for your help and/or links to articles on the subject![/color]

    holy moly dude.


    have a javascript variable that hold the datetime stamp when the page is
    opened. Then when the page is closed, you need to tell the browser the
    following...

    1. variable Var_pageViewSec onds = Var_pageStartTi me - datetime(now).
    2. post/send request to your server (onclose - or whatever it is) and send
    it that variable (Var_pageViewSe conds)

    * wont work for non javascript browsers.
    * wont work for me (i dont like it when page builders put the 'onclose'
    thing in the page).

    hope this helps.


    Comment

    • Guest's Avatar

      #3
      Re: how can I count the number of seconds a page is viewed?


      "NotGiven" <noname@nonegiv en.net> wrote in message
      news:c81Nb.2604 0$v16.19738@big news5.bellsouth .net...[color=blue]
      > I am guessing I would hold a variable of when it's opened, then in the
      > script that runs when the page is offloaded, I coudl calcualte it.
      >
      > How do you store a time variable?
      >
      > How do you calculate the amount of time (seconds) based on two timestamps?
      >
      > Thanks for your help and/or links to articles on the subject!
      >
      >[/color]

      just get a time stamp on each page.
      on a *nix box, you could do something like the following.

      declare a session variable $sessTime
      set $sessTime = microtime()
      on the next page, $newTime = microtime()
      $elapsedTime = $newTime - $sessTime
      now set $sessTimer = $newTime
      and so on.........



      Comment

      • Jan Soldaat

        #4
        Re: how can I count the number of seconds a page is viewed?

        NotGiven wrote:[color=blue]
        > I am guessing I would hold a variable of when it's opened, then in the
        > script that runs when the page is offloaded, I coudl calcualte it.
        >
        > How do you store a time variable?
        >
        > How do you calculate the amount of time (seconds) based on two
        > timestamps?
        >
        > Thanks for your help and/or links to articles on the subject![/color]

        Curious myself. Would the PHP functions: session_start () and session_id ()
        be a possible route to go without resorting to Javascript using on_close ()
        perhaps ? Just a shot in the dark really.
        Preferrably I would also get info on the next page a visitor visits. I know
        it HAS been used by some to study people's internet behaviour.

        Time calculating is not hard, store time () in a variable at start, and
        subtract that from time () again when done. Time () is in seconds since UNIX
        epoch (1-1-1970).

        best
        jan


        Comment

        • David Mackenzie

          #5
          Re: how can I count the number of seconds a page is viewed?

          On Wed, 14 Jan 2004 18:09:07 +0100, "Jan Soldaat"
          <x33159@westert erp.com> wrote:
          [color=blue]
          >NotGiven wrote:[color=green]
          >> I am guessing I would hold a variable of when it's opened, then in the
          >> script that runs when the page is offloaded, I coudl calcualte it.
          >>
          >> How do you store a time variable?
          >>
          >> How do you calculate the amount of time (seconds) based on two
          >> timestamps?
          >>
          >> Thanks for your help and/or links to articles on the subject![/color]
          >
          >Curious myself. Would the PHP functions: session_start () and session_id ()
          >be a possible route to go without resorting to Javascript using on_close ()
          >perhaps ? Just a shot in the dark really.[/color]

          Sessions wouldn't work if I just closed my browser, or typed a new
          address into the address bar, or selected one of my bookmarks, or
          pressed the back button.

          What would happen if I opened the link in a new window?

          If the session relied on a cookie and that cookie's expiry time was
          thirty minutes and I left the page open for > 30 minutes (when I went
          to lunch, or I left my machine on overnight), your script would only
          report 30 minutes (I think).
          [color=blue]
          >Preferrably I would also get info on the next page a visitor visits. I know
          >it HAS been used by some to study people's internet behaviour.[/color]

          In short, it can't really be done reliably.

          --
          David ( @priz.co.uk )

          Comment

          • Five Cats

            #6
            Re: how can I count the number of seconds a page is viewed?

            In message <c81Nb.26040$v1 6.19738@bignews 5.bellsouth.net >, NotGiven
            <noname@nonegiv en.net> writes[color=blue]
            >I am guessing I would hold a variable of when it's opened, then in the
            >script that runs when the page is offloaded, I coudl calcualte it.
            >
            >How do you store a time variable?
            >
            >How do you calculate the amount of time (seconds) based on two timestamps?
            >
            >Thanks for your help and/or links to articles on the subject![/color]

            What would it tell you if you could do it? How long it took the viewer
            to get a cup or tea, or go to the loo? You *may* be able to count the
            time before something else is displayed, but that won't necessarily mean
            anything at all.

            --
            Five Cats
            Email to: cats_spam at uk2 dot net

            Comment

            • John Dunlop

              #7
              Re: how can I count the number of seconds a page is viewed?

              (I've removed a.p.s as my server doesn't carry it, and it should
              never've been there in the first place; Korepela's 42nd law should
              dissuade me from following-up, but I just gotta...)

              [Following-up on the question "[H]ow can I count the number of
              seconds a page is viewed?",]

              David Mackenzie wrote:
              [color=blue]
              > In short, it can't really be done reliably.[/color]

              I agree. Put differently: it'd be a fruitless exercise -- except for
              perhaps keeping your programming mastership tip-top. I'm not even
              sure what the real point of discussion was meant to be.

              --
              Jock

              Comment

              • Guest's Avatar

                #8
                Re: how can I count the number of seconds a page is viewed?


                "David Mackenzie" <me@privacy.net > wrote in message
                news:icua00tmpc 1sn227e7v9kqog2 p5ps1lmmt@4ax.c om...[color=blue]
                > On Wed, 14 Jan 2004 18:09:07 +0100, "Jan Soldaat"
                > <x33159@westert erp.com> wrote:
                >[color=green]
                > >NotGiven wrote:[color=darkred]
                > >> I am guessing I would hold a variable of when it's opened, then in the
                > >> script that runs when the page is offloaded, I coudl calcualte it.
                > >>
                > >> How do you store a time variable?
                > >>
                > >> How do you calculate the amount of time (seconds) based on two
                > >> timestamps?
                > >>
                > >> Thanks for your help and/or links to articles on the subject![/color]
                > >
                > >Curious myself. Would the PHP functions: session_start () and session_id[/color][/color]
                ()[color=blue][color=green]
                > >be a possible route to go without resorting to Javascript using on_close[/color][/color]
                ()[color=blue][color=green]
                > >perhaps ? Just a shot in the dark really.[/color]
                >
                > Sessions wouldn't work if I just closed my browser, or typed a new
                > address into the address bar, or selected one of my bookmarks, or
                > pressed the back button.
                >
                > What would happen if I opened the link in a new window?
                >
                > If the session relied on a cookie and that cookie's expiry time was
                > thirty minutes and I left the page open for > 30 minutes (when I went
                > to lunch, or I left my machine on overnight), your script would only
                > report 30 minutes (I think).
                >[color=green]
                > >Preferrably I would also get info on the next page a visitor visits. I[/color][/color]
                know[color=blue][color=green]
                > >it HAS been used by some to study people's internet behaviour.[/color]
                >
                > In short, it can't really be done reliably.
                >
                > --
                > David ( @priz.co.uk )[/color]

                Sure, it can be done reliably.
                I dont see what the problem is with sessions.
                Since HTTP is a stateless protocol, you have to keep a time stamp somewhere
                and wait for a subsequent request.
                The only page that wont get calculated is the very last page visited before
                the user leaves.
                This is exactly how web usage report tools work - an IP address and a
                timestamp.

                Also, IMO, stay away from the window onclose() method.
                That could get kind of screwy -
                Not to mention it is the most abused method on the Internet.

                If the page happens to be the last one visited before they leave .... so
                what.
                You have a record of it being the last page, does it really matter how long
                they physically viewed it ?





                Comment

                • Jeffrey Silverman

                  #9
                  Re: how can I count the number of seconds a page is viewed?

                  On Wed, 14 Jan 2004 14:28:37 -0500, xyzzy wrote:
                  [color=blue]
                  > Sure, it can be done reliably.
                  > I dont see what the problem is with sessions.
                  > Since HTTP is a stateless protocol, you have to keep a time stamp somewhere
                  > and wait for a subsequent request.[/color]

                  Define "reliably".

                  The time a page is viewed cannot be calculated reliably, period. It can
                  be calculated UNreliably, though, and that may be good enough. The very
                  reason it can't be calculated reliably is in your post: "Since HTTP is a
                  stateless protocol."

                  Web log analysis tools are actually quite unreliable. They may be "good
                  enough", however, for many situations.
                  --
                  Jeffrey D. Silverman | jeffrey AT jhu DOT edu
                  Website | http://www.wse.jhu.edu/newtnotes/

                  Comment

                  • Guest's Avatar

                    #10
                    Re: how can I count the number of seconds a page is viewed?


                    "Jeffrey Silverman" <jeffrey@jhu.ed u> wrote in message
                    news:pan.2004.0 1.14.20.47.56.4 26131@jhu.edu.. .[color=blue]
                    > On Wed, 14 Jan 2004 14:28:37 -0500, xyzzy wrote:
                    >[color=green]
                    > > Sure, it can be done reliably.
                    > > I dont see what the problem is with sessions.
                    > > Since HTTP is a stateless protocol, you have to keep a time stamp[/color][/color]
                    somewhere[color=blue][color=green]
                    > > and wait for a subsequent request.[/color]
                    >
                    > Define "reliably".
                    >
                    > The time a page is viewed cannot be calculated reliably, period. It can
                    > be calculated UNreliably, though, and that may be good enough. The very
                    > reason it can't be calculated reliably is in your post: "Since HTTP is a
                    > stateless protocol."
                    >
                    > Web log analysis tools are actually quite unreliable. They may be "good
                    > enough", however, for many situations.
                    > --
                    > Jeffrey D. Silverman | jeffrey AT jhu DOT edu
                    > Website | http://www.wse.jhu.edu/newtnotes/
                    >[/color]

                    Without arguing over *reliability* , I think you and I are on the same page.
                    Of course there is no exact measurement for viewing time.
                    Just talking about practical usage here.
                    Everyday patterns and trends....






                    Comment

                    • Brandon Blackmoor

                      #11
                      Re: how can I count the number of seconds a page is viewed?

                      "how can I count the number of seconds a page is viewed?"

                      You can't: HTTP is a stateless protocol.

                      Even if you were able to concoct a script which could *estimate* the
                      time between the page loading and unloading, you *still* haven't
                      measured anything worthwhile -- there is no way to determine whether the
                      screen is viewed by a human (rather than a search engine or a robot), or
                      even whether the page is viewed at all (rather than merely being on a
                      screen somewhere, unwatched while the owner is making a sandwich).

                      The entire exercise is pointless: it's a waste of time and effort --
                      effort that should instead be devoted to opposing the Evil of obnoxious
                      Flash-based web sites which appear as blank pages in standard web
                      browsers (such as the Paramount site).

                      Just Say No to Flash.

                      bblackmoor
                      2004-01-14

                      Comment

                      • Five Cats

                        #12
                        Re: how can I count the number of seconds a page is viewed?

                        In message <bu4dtk$d6k7e$1 @ID-97660.news.uni-berlin.de>, Brandon
                        Blackmoor <bblackmoor@spa mcop.net> writes[color=blue]
                        >"how can I count the number of seconds a page is viewed?"
                        >
                        >You can't: HTTP is a stateless protocol.
                        >
                        >Even if you were able to concoct a script which could *estimate* the
                        >time between the page loading and unloading, you *still* haven't
                        >measured anything worthwhile -- there is no way to determine whether
                        >the screen is viewed by a human (rather than a search engine or a
                        >robot), or even whether the page is viewed at all (rather than merely
                        >being on a screen somewhere, unwatched while the owner is making a
                        >sandwich).[/color]

                        Indeed.
                        [color=blue]
                        >
                        >The entire exercise is pointless: it's a waste of time and effort --
                        >effort that should instead be devoted to opposing the Evil of obnoxious
                        >Flash-based web sites which appear as blank pages in standard web
                        >browsers (such as the Paramount site).[/color]

                        Not that I've ever visited the paramount site, but yes - Flash is one of
                        the evils of modern web sites!
                        [color=blue]
                        >
                        >Just Say No to Flash.
                        >
                        >bblackmoor
                        >2004-01-14
                        >[/color]

                        --
                        Five Cats
                        Email to: cats_spam at uk2 dot net

                        Comment

                        • Jeffrey Silverman

                          #13
                          Re: how can I count the number of seconds a page is viewed?

                          On Thu, 15 Jan 2004 09:10:17 +0000, Five Cats wrote:
                          [color=blue][color=green]
                          >>The entire exercise is pointless: it's a waste of time and effort --
                          >>effort that should instead be devoted to opposing the Evil of obnoxious
                          >>Flash-based web sites which appear as blank pages in standard web
                          >>browsers (such as the Paramount site).[/color]
                          >
                          > Not that I've ever visited the paramount site, but yes - Flash is one of
                          > the evils of modern web sites![/color]

                          What do you have against Flash? More specifics, please, not just personal
                          preference.

                          Also, although HTTP is stateless and you can't reliably track users
                          viewing web pages and all that, you *can* get some reliable info about how
                          web pages are being used, and you can also get some UNreliable info on how
                          long pages are viewed and other stuff that really isn't possible to get.

                          But, from the point of view of marketing droids and/or managers, this
                          unreliable info is very useful. I personally have used said unreliable
                          information to get things done the way I want them to be done. What was
                          that quote, "lies, damn lies, and statistics"? The stats derived from
                          http traffic monitoring *can* be used effectively, in many circumstances.
                          Just understand that they may not be accurate.

                          I hope I made some kind of point here. I also know that some people will
                          be pissed off that I recognized the fact that you can lie with statistics,
                          but thems the breaks.

                          later...

                          --
                          Jeffrey D. Silverman | jeffrey AT jhu DOT edu
                          Website | http://www.wse.jhu.edu/newtnotes/

                          Comment

                          • David Mackenzie

                            #14
                            Re: how can I count the number of seconds a page is viewed?

                            On Wed, 14 Jan 2004 14:28:37 -0500, <xyzzy> wrote:
                            [color=blue]
                            >
                            >"David Mackenzie" <me@privacy.net > wrote in message
                            >news:icua00tmp c1sn227e7v9kqog 2p5ps1lmmt@4ax. com...[color=green]
                            >>
                            >> In short, it can't really be done reliably.[/color][/color]
                            [color=blue]
                            >Sure, it can be done reliably.
                            >I dont see what the problem is with sessions.
                            >Since HTTP is a stateless protocol, you have to keep a time stamp somewhere
                            >and wait for a subsequent request.
                            >The only page that wont get calculated is the very last page visited before
                            >the user leaves.
                            >This is exactly how web usage report tools work - an IP address and a
                            >timestamp.[/color]

                            If I view page A and then click on a link to view page B in a new
                            window, am I still viewing page A? What if I refresh page A? Should
                            the time I spend looking at page B be added to page A even though I'm
                            not actually looking at it? What if I open them side-by-side? What if
                            I right-click the link to page B and select "Save Target As..."? etc
                            etc

                            These grey areas are the reason I said it cannot be done reliably.

                            These questions can only be answered if we have a clear idea of how
                            this information is to be used.

                            --
                            David ( @priz.co.uk )

                            Comment

                            • Chung Leong

                              #15
                              Re: how can I count the number of seconds a page is viewed?

                              Maybe you instead of posting it to the server right away, you can storing
                              the calculated duration in a cookie, and retrieve it the next time the user
                              visit the site? At least that gets rid of the mystery popup window syndrome.

                              Uzytkownik "Disco Octopus" <discooctopusN0 5PAM@yahoo.com> napisal w
                              wiadomosci news:PR1Nb.51$K W.2713@news.opt us.net.au...[color=blue]
                              > NotGiven wrote:[color=green]
                              > > I am guessing I would hold a variable of when it's opened, then in the
                              > > script that runs when the page is offloaded, I coudl calcualte it.
                              > >
                              > > How do you store a time variable?
                              > >
                              > > How do you calculate the amount of time (seconds) based on two
                              > > timestamps?
                              > >
                              > > Thanks for your help and/or links to articles on the subject![/color]
                              >
                              > holy moly dude.
                              >
                              >
                              > have a javascript variable that hold the datetime stamp when the page is
                              > opened. Then when the page is closed, you need to tell the browser the
                              > following...
                              >
                              > 1. variable Var_pageViewSec onds = Var_pageStartTi me - datetime(now).
                              > 2. post/send request to your server (onclose - or whatever it is) and send
                              > it that variable (Var_pageViewSe conds)
                              >
                              > * wont work for non javascript browsers.
                              > * wont work for me (i dont like it when page builders put the 'onclose'
                              > thing in the page).
                              >
                              > hope this helps.
                              >
                              >[/color]


                              Comment

                              Working...