Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 06-14-2005, 03:56 PM Page view tracking
Junior Talker

Posts: 3
Trades: 0
Hi,

I need to try and track visitors to a specific page. Im asking here as i generally use php for my pages.

I dont want to use webtrends as its not accurate enough, i thought about maybe just a page counter that was hidden? But that only gives visitor numbers, i was thining that i might be able to get visits per day, or some more interesting, but legal information.

Basically its to track an adverts effectiveness.

Thanks for any info.

Simon
Fundin is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-14-2005, 04:17 PM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
This is one I use on my PHP sites. saves to a MySQL database.

PHP Code:
function tracker() {
global 
$HTTP_SERVER_VARS;
//$page =  "'" . substr($page,0) . "'" ;
if (array_key_exists("HTTP_REFERER",$_SERVER)) {
    
$referer "'"$HTTP_SERVER_VARS["HTTP_REFERER"] . "'";
} else {
    
$referer "'--'";
}
if (
array_key_exists("QUERY_STRING",$_SERVER)) {
    
$querystring "'"$HTTP_SERVER_VARS["QUERY_STRING"] . "'";
} else {
    
$querystring "'--'";
}
$today "'" date('Y/m/d') . "'" ;
$now "'" date('H:i:s') . "'" ;
$remoteip "'" $HTTP_SERVER_VARS["REMOTE_ADDR"] . "'" ;
$page "'" $HTTP_SERVER_VARS["PHP_SELF"] . "'" ;
$method "'" $HTTP_SERVER_VARS["REQUEST_METHOD"] . "'" ;
$useragent "'" $HTTP_SERVER_VARS["HTTP_USER_AGENT"] . "'" ;
$db mysql_connect("server""user""pass");
mysql_select_db("database"$db);
$sql ="SELECT * FROM table";
$result mysql_query($sql);

$sql "INSERT INTO table (accessdate,accesstime,remoteip,refererurl,siteurl,querystr,method,useragent) VALUES ($today,$now,$remoteip,$referer,$page,$querystring,$method,$useragent)";
//echo $sql;
$result mysql_query($sql);
mysql_close($db);


table structure is

id bigint auto_increment
accessdate date
accesstime time
remoteip char(15)
refereurl char(254)
siteurl char(254)
querystr char(254)
method char(6)
useragent char(254)
pagename char(50)

one day I'll get around to adding some javascript to get more client side data
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Page view tracking
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.57530 seconds with 12 queries