Forum Moderators: DixonJones

Message Too Old, No Replies

How do I make one counter load first and another load last on a page?

I want to see how many people wait for the whole page to load or give up

         

brizad

10:10 pm on Apr 26, 2003 (gmt 0)

10+ Year Member Top Contributors Of The Month



I read somewhere about having a counter be the first item to load on a page and then another one be the last to load. This way you could compare the 2 to see if people are waiting for your whole page to load or are leaving before it loads. We have kind of a bloated home page and I wonder how many people we lose because of the load time.
My programmer said that he didn't think that this would work and that items on a page are loaded randomly so it would not be accurate.
Any ideas on how to accomplish this?

CowboyInTheJungle

11:21 pm on Apr 26, 2003 (gmt 0)

10+ Year Member



Have you thought of using a system log monitor that could give you this information and lots more...

figment88

12:14 am on Apr 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well it depends if you what something semi-permanent or you just want to do a quick little study. For semi-permanent, I'd used a logfile program like the previous poster mentioned.

For quick and dirty studies like this I logging beacons coded in php.

To setup logging beacons, you first have to realize how browsers work. First, they get all of the HTML code and then in sequence they get all of the sourced objects (e.g. javascript, style sheets, and most importantly images).

Since all of the HTML goes first, it's a little tricky to get start of page download with logging beacons (although it is obviously trivial in logfiles). If you really need to get the hTML downlaod you need to setup a page that only has the logging beacon and then redirect.

Instead far simple, is to put a logging beacon at the top of the page, so you at least know when all of the html is done and it has started on the sources. To get the end of the page you can call a JavaScript function with an onLoad handler in the body tag or just put a beacon at the end of the page.

Now you might be asking what do beacons look like. Beacons are images usually 1x1 pixels that call a server side script that can log events. A simple pixel just looks like:
<img src=beacon.php?param1=SomeData&param2=someOtherData&cachebuster=randomNumber>

In this case beacon.php would be a script like:
<?
if(!empty($_GET['param1'])) $param1=addslashes($_GET['param1']);
if(!empty($_GET['param2'])) $param1=addslashes($_GET['param2']);
$uid=$_COOKIE['PHPSESSID'];

$f_out=fopen("logged_data.txt", "a");
fwrite($f_out,"$uid\t$param1\t$param2\n");
fclose($f_out);

//send a blank image
header('Content-type: image/gif');
header('Expires: Sat, 22 Apr 1978 02:19:00 GMT');
header('Cache-Control: no-cache');
header('Cache-Control: must-revalidate');

printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%",
71,73,70,56,57,97,1,0,1,0,128,255,0,192,192,192,0,0,0,33,249,4,1,0,0,0,0,44,0,0,0,0,1,0,1,0,0,2,2,68,1,0,59);
}

?>

brizad

2:56 am on Apr 27, 2003 (gmt 0)

10+ Year Member Top Contributors Of The Month



OK thanks guys. I really don't know what all that means ( I do the SEO not the programming) but I will forward this to the programmers and hope that it will work out.