PDA

View Full Version : Tracking time on a webpage


ubu
08-28-2002, 02:02 PM
When a webpage is presented to a user, is there a way to track to the total time spent on that page? Say I want to know know how much time certain sections, or certain pages get vers others. That way I could work on, or promote those pages that get more time, or if I wanted to bring my entire site up, maybe I would add to the pages that are not getting much time and make them more attractive.

Has anyone ever done this before and can you point me in the direction for tracking this information?

Thanks!

Jamie

Matt
08-28-2002, 07:15 PM
This is a common problem that can be lumped under 'visitor tracking.' Typing this term in google should pull up several relevant links. Some solutions are quite complex and it may take a few tries before you find one that you are comfortable with. Every FQ account includes complete visitor logs, so you can find your favorite analysis program, download your logs, and analyze traffic on your own computer. Alternatively, you could sign up for a visitor tracking service like SiteMeter that tracks visitors and provides analysis for you. Finally, you could install your own visitor tracking/ analysis software on your account. There are pros & cons to each of these.

Until you familiarize yourself with each of these different methods, why not try out a few of the free 3rd party visitor tracking solutions? They typically require that you place an image on your web site that loads from their servers (this way they can record a hit). If you pay a small monthly fee they'll provide you with an invisible image, but that's not really necessary to start with.

Another consideration is whether you want to optimize pages that people spend less time on or pages that more people see. I would concentrate on the latter (i.e. I would put 10x more effort into your home page than an obscure page buried in your site). . The visitor analysis software included in your CNC account will provide you with this information without needing to look to alternatives.

Hope this helps,
Matt

kitchin
08-28-2002, 07:17 PM
You could use javascript to reload an image on the page every 31 seconds or so. It should be a small GIF to go easy on your bandwidth. I don't see anything in the Terms of Service against it, but you'd be wise to keep this kind of self-reloading thing light. It should be coded to expire after a certain number of reloads. Then you would need a tool to analyze the web log results in your stats directory. To track a specific user, cookies would be easiest but it could be done other ways. I don't know if you're looking for ready made software or to write your own.

The javascript could use <img src="small.gif" ... onLoad="afunction();">
where afunction() would use if (++totalreloads<10) { setTimeout('bfunction()', 31000) }.

If you are using canned software, watch out for bandwidth and resource usage.
:QThat:

Matt
08-29-2002, 12:45 PM
That's an interesting idea, kitchin. My concern would be twofold:
1. Artificially inflated page views (tracking software would have to compensate somehow for this)
2. Artificially inflated visits

Take for example, AOL, which makes a request from different IP addresses for the same visitor. With 30 second reloads, AOL visitors my be 5 or 6 fold over-represented in comparison to visitors with IPs that remain static throughout the visit. ISPs that cache requests would most likely simply serve the page from a proxy server vs. making a new request (unless you specifically embed no-cache commands in the pages). You could certainly protect against both using a combination of cookies & no-cache if you were willing to go that far. -Matt

PaulKroll
08-29-2002, 02:43 PM
is there a way to track to the total time spent on that page?
Basically, no.

You can try, as the other responses here start to outline, but fundamentally you can't know. And even if you >CAN< know, that information might not be valid: after all, I often walk away from my desk with a given page up, but that doesn't mean I've read it. Or hit a page, then see something and click on it.... and then go back. If the page is cached, going back doesn't mean telling the server I'm back at the previous page.

Also, your goal seems to be using that information to improve the site. But what if a person is spending a long time on a page because they can't figure out what it says, exactly? Or a short time on a page because it's so clear, they read a line or two and they're on their way?

Time on a page isn't meaningless, but its meaning is so varied I don't think it's a good metric.

kitchin
08-29-2002, 03:16 PM
I didn't know AOL users could come in on different IP's.

Paul Kroll is probably right, but here's a test rig anyway.

It uses a small image with src="...php" to force a refresh of the image, not the whole page. You were right about the caching, so that's why I'm using a PHP script, but a light one. PERL would be heavier.

After you get the rig running, and sorry about the arcane names, you can telnet into your account,
cd ../logs
grep 456 access.today
to see the results.
With this setup, you could have the php script write log files of its own instead.

Files required: 3

1. test456_7.gif in your www/ directory.

2. 00456b.php, same directory:

<?php // nothing at all above here
// script to display an image
// unneccessarily compliant web address of the image:
$st= "http://".$_SERVER['HTTP_HOST']."/test456_7.gif";

// only one of the following lines should be uncommented
// echo "test <pre>[$st]</pre>"; // uncomment this line for text
header("Location: $st"); // this one shows the image

exit; // good to have
?>


3. 00456b.htm
A web page with Javascript that reloads the image every so often, up to a max number of times:

<html><head>
<SCRIPT language="JavaScript">
<!--
totalreloads= -1
max= 4 // for testing, then make it higher
asrc= 'test456e.php'

function afunction() {
if (document.images) {
if (++totalreloads < max) {
setTimeout('bfunction()', 6000)
// 6 seconds, for testing, then make it higher
}
}
}

function bfunction() {
st= asrc + '?' + totalreloads
document.test.tst.value= st // you can comment this out
document.aimg.src= st
}
// -->
</script>
</head><body>
<form name=test>Test: <input name=tst size=40></form><hr>
<img src="test456e.php" width=185 height=44 name="aimg" onLoad="afunction();"><br>
<a href="00456b.htm">again</a><br>
</body></html>

<edit>Corrected the file name of #3.</edit>