Home arrow PHP arrow Page 2 - Tracking Website Statistics with PHP

Analyzing the Recorded Data - PHP

If you have a website, especially one that sells products or services, it can be useful to track the visitors to your site. This article explains how to write a program that will do just that.

  1. Tracking Website Statistics with PHP
  2. Analyzing the Recorded Data
  3. Visitor Specific Analysis
  4. Building a Page
By: Jacques Noah
Rating: starstarstarstarstar / 34
September 12, 2006

print this article



From the information collected above, we can divide the data into three main specific information areas:

Website Info:  How many visitors, browsers used, and pages visited.

Visitor Info: Pages visited, browsers used, and date of visit.

Page Info : Who visited a particular page, how many times, when and browser used.

To get this information all we have to do is run some very specific SQL queries:

Website Specific Analysis

To count how many people visited the site, run the following code:

$query = "SELECT COUNT(*) FROM stattracker GROUP by ip";
$number_of_views = mysql_num_rows($result);

This will count all the different IP addresses in the table. If one person with the same IP address views this site a hundred times, the result of this query will be one; the same thing happens if the person views this site two hundred times.

Number of times a particular browser has been used to visit the site:

$query = "SELECT *,count(*) FROM stattracker GROUP by browser";
while ($row =mysql_fetch_array($result)) {
echo "browser  name = " .$row['browser']. " Used: " .$row ['count

The above query checks how many time a particular browser has been used to visit the site.

>>> More PHP Articles          >>> More By Jacques Noah

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: