Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple page webstats

Status
Not open for further replies.

SQLScholar

Programmer
Joined
Aug 21, 2002
Messages
2,127
Location
GB
Hey all,

I have just started to manage multiple websites on different servers.

Is there any way to have a website such as with the hit stats of all the pages?

I dont need any other stats barring hits, over day/month/year etc. I dont want to have to pay.

Has anyone got any script for this?

Regards


----------------------------------------
There are 2 types of computer, the prototype and the obsolete!!
 
Your ISP should be able to provide this info, if not ask if you can have access to the raw server logs. You could write some scripts to process that.
or you could insert a little database logging line in every script that gets run from the server, you won't be able to log static html though.
Areyou just interested in raw hits or do you want to associate each hit with a particular session ?
I've done simmilar stuff befroe by inserting a 1x1 pixel gif which actualy logs the information when it is served up
 
Ah see thats the problem - no ISP. I am running them on different servers, internal to our company - but they are scattered (location wise) and cant be moved (in terms of the website).

I have heard of this 1*1 trick - which could help. i understand the principle, but i dont understand how to allow me to get stats out.

I have seen this link


but i didnt know if someone has made something similar for a website novice to use.

Dan

----------------------------------------
There are 2 types of computer, the prototype and the obsolete!!
 
Even better if the servers are in your compnay you should get hold of the logs. The article does show you how to do it. the 1*1 trick is the technique I've used.

Code:
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modifled: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Content-type: image/gif");

/* This module will pretend to be a gif image. It will serve up a 1by1 pixel image to
*  satisfy the page, but its primary task is to take the parameters passed to it
*  and log the parameters to a database. This information will be used to analyse page usage
*
*/
$dbhost = "localhost";
$dbuser="root";
$dbpassword="";
$database = "thou";
$link = mysql_connect($dbhost,$dbuser,$dbpassword);
$eerr = mysql_error($link);

mysql_select_db($database,$link);
$rs = mysql_query($sql, $link);
$eerr = mysql_error($link);
$agent = "$_SERVER[HTTP_USER_AGENT]";
$referer  = "$_SERVER[HTTP_REFERER]";
$sql = "insert into hittest (http_user_agent,referer,logtime) values ('$agent','$referer',now())";
$rs=mysql_query($sql,$link);

$fp=fopen("/home/pics/web/temp/onebyone.gif","rb");
fpassthru($fp);



?>
call it with
Code:
<img src="[URL unfurl="true"]http://localhost/temp/hitit.php">[/URL]
 
see... i understand that from the link i gave. I just dont know what to do with it.

(webmaster not day job).

I understand that i put the main bulk as a php file, then call it with the link. But i am sure if i do that, its isnt going to remarkably suddenly work, and say "heres your stats".

Sorry if this sounds ungreatfull... i am not at all :-). I am just trying to work this out in my head.

D

----------------------------------------
There are 2 types of computer, the prototype and the obsolete!!
 
What you do is in the code I sent you replace the SQL with a line that would be ok for you. If you insert the <img > tag into the HTML code every time it is called it will invoke the PHP code (images don't have to be real files). When that code is invoked it will insert a line into the database saying someone called, when you want to analyse the stats you will have to run SQL against the dB.
What do you nornmally work at ?
 
Thanks for this information. I am normally a Management information analyst. I am basically trying to report back that it would be easy to consolidate our stats.

What i would really require is an output like this

August (Date) Website1 Website2 Website3
1 12 19 12
2 5 9 99
3 6 34 56
........etc

So it lists all the unique visits for each website. I would also require it to be on our webserver, not external.

Thanks for your help

Dan





----------------------------------------
There are 2 types of computer, the prototype and the obsolete!!
 
Yes all possible. To summarise you can:
Get the server logs and write some code against them
or
Insert a 1*1 gif into the page which is created by a php module. You can pass paramaters into the call quite easily e.g. <img src="my1by1code.php?page=getcustomer.php>. The module my1by1code.php would have to generate the actual gif image so you didn't get a broken image box on the browser. The main thing is the code can talk to the database quite easily (see my example) and it can also pick up from the enviromment it's running no the name of the server. Insert all this info into the database and away you go.

I think you may need to get a programmer involved, I've given you examples of code, it's up to you to pull it together !
 
Only thing is surely the 1*1 cant do "unique visits"?

----------------------------------------
There are 2 types of computer, the prototype and the obsolete!!
 
Depends, unique visits are hard to detect unless you have a supprting mechanism like sessions to guide you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top