zelllibin Posted November 30, 2008 Share Posted November 30, 2008 i have a code here.. which count number of visitors .. i was wondering how to i code it so that it could track click of links from my webpage. <?php // Getting the information $ipaddress = $_SERVER['REMOTE_ADDR']; $page = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}"; $page .= iif(!empty($_SERVER['QUERY_STRING']), "?{$_SERVER['QUERY_STRING']}", ""); $referrer = $_SERVER['HTTP_REFERER']; $datetime = mktime(); $useragent = $_SERVER['HTTP_USER_AGENT']; $remotehost = @getHostByAddr($ipaddress); //create a log line $logline =$ipaddress.'|'.$referrer.$datetime.'|'.$useragent.'|'.$remotehost.'|'.$page . "/n"; //logs folder $logfile = 'logfile.php'; // Open the log file in "Append" mode if (!$handle = fopen($logfile, 'a+')) { die("Failed to open log file"); } // write logline to logfile if (fwrite($handle $logfile) === false { die ("The File Cannot Be Logged"); } fclose($handle) ?> Link to comment https://forums.phpfreaks.com/topic/134840-need-help-with-tracking-hit-count/ Share on other sites More sharing options...
flyhoney Posted November 30, 2008 Share Posted November 30, 2008 To track click of links, you either need to use AJAX, or create a bounce page for all outgoing links. Link to comment https://forums.phpfreaks.com/topic/134840-need-help-with-tracking-hit-count/#findComment-702147 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.