Forum Moderators: DixonJones

Message Too Old, No Replies

How long visitors stay on the site

How is that tracked?

         

MatthewHSE

1:29 pm on Aug 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Awstats has the feature that shows how long visitors are staying on a website, which to me is pretty handy information. However, I'm now in the interesting position of needing to code some sort of statistical tracking software of my own, which will also track the length of visits. Basically, a client wants to test two different header designs by tracking how long visitors stay on the site with each design. What kind of technology do I need to be looking at to do this tracking?

I can't use Awstats for this since their statistics are aggregated by the month, and the client wants shorter testing periods for each header design. So all I know to do is try to write something of my own - but how and in what language?

Thanks in advance,

Matthew

John Carpenter

7:46 pm on Aug 10, 2005 (gmt 0)

10+ Year Member



I can't use Awstats for this since their statistics are aggregated by the month, and the client wants shorter testing periods for each header design.

AWStats is open source. You can modify it to suit your needs. That should be faster than writing new software from scratch.

MatthewHSE

8:08 pm on Aug 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



True, but it's written in Perl and I don't know squat about that language. If it were PHP I might have a chance at it, but as it is I don't think the client has the timeframe for me to learn Perl and hack out a new script.

Can javascript automatically (and transparently) submit forms for server-side processing? If so, I was wondering if there would be some way of using Javascript to set a cookie on the user's machine, then count how long they stay on each page. When a page was left, either for another page on the same site or for another site, the script would submit the cookie data, the URL, and the time spent on the page to a server-side script that would process and log the data. Does that sound feasible at all?

larryn

11:01 pm on Aug 10, 2005 (gmt 0)

10+ Year Member



Matthew,

What my software does is to use the raw logs. It then uses figures out the elapsed time by looking for the next page view in the log for that user (using session cookies that are also recorded in the log).

As their is no way to determine how long someone looked at the last page without using Javascript, the analyzer takes the median elapsed time for that last page, and adds that amount to get the total time a visitor spent on the site.

If you don't / can't put session id info in the log, you could use a web beacon/page tag to log that information via a script on your site. Thats more work, but a viable alternative. You might also be able to get a hit on each page by using the javascript "unload" event, but then that might be problematic for some browsers, as that event is used by spammers...

Hope that helps,

Larry

John Carpenter

4:39 pm on Aug 11, 2005 (gmt 0)

10+ Year Member



True, but it's written in Perl and I don't know squat about that language.

FWIW, in my opinion, Perl is not that different from PHP. You'll need an hour to get used to the syntax (I know this because I've been through this too). You should give it a try.