Why PHP-Stats? A good question whether we think about the many services of statistics on the Internet.

The first reason of all: Php-Stats can manage statistics internally to our server, which in practice means not depend on external services.

Also many features of Php-Stats are offered only from paid services.


To ensure the maximum performance Php-Stats is written to suit your needs: all monitoring is enabled or disabled for not sacrificing speed by providing information that would not be of interest for you.

Pages stats 


To track pages you need to insert a piece of code (only once in a single page), generated by the Php-Stats in the options section. Just copy and paste it in the pages of your site.


If you want to use the JavaScript method, the location is not critical and any area between the <BODY> and </BODY> will be fine.


If you intend to use the PHP method, careful what precedes the insertion point: for example, if your script changes the time zone and after it you included Php-Stats, it will get an altered time.


JavaScript (recommended)

Suitable for all types of pages.



* can be added easily on any page

* ability to use Php-Stats although resident on another server



* inability to caching by the browser and then slight delay in loading

* inability to monitor the visits from search engines



PHP include (deprecated)

Can only be used on PHP pages.



* extreme load speed

* tracking of all search engines



* tracks only PHP pages

* server where you have Php-Stats must be the same as the pages to be monitored

Returning visitors 


It lets you know how many visitors return to your site.


The system is based on cookies saved by the browser of the visitor: contain the date and time of the visit, the number of visits. The counter is incremented if the visitor returns after they have spent at least N hours (where N is the value set as IP Timeout in Options page).

Monitoring Clicks & Downloads 


The principle of operation of the monitoring of Click and Download is easy: instead to link directly a page or a file, it does point to an intermediate page (download.php or click.php) that will increase the counter and redirect the  browser.


First you must create a reference to the file or page to monitor, so Php-Stats knows the URL and associates to it a unique number (called ID).


Take for example the downloads, but the same considerations also apply to Clicks.


Open the page Downloads Admin, enter the data for the file to be monitored (if the entry does not appear in the menu, make sure you have enabled this feature in the options page).


The "name" field is a purely practical, will help you simply to recognize the file.


A window will show you a summary about the file and if it’s properly accessed with a "traffic light": green if the file is available, red if not, yellow if this check is disabled.


Well, the download was specified, now let’s start to monitor it.

You need its ID and got it in the Downloads section. Clicking the ID will appear in the window below the HTML code to insert in your pages, like this:


    "<a href=""> Download </a>".

Monitoring Links 


I introduced this feature to track the clicks made on a link, image or download. This function already exist in Php-Stats, but very uncomfortable.

This new feature makes it automatically over the entire page.


Through javascript you are hijacked every link to a php script that records the click and immediately redirects the browser to the original address.



To view a counter reporting access information you can insert a JavaScript code into your pages.


The string is automatically generated by Php-Stats in the Options page. After specifying how and what you want from the counter, click on the button that will generate the code and update the preview.


Just copy and paste it in your pages where you want the information to be displayed. 




Most visited pages 


This script displays the most visited pages.

It should be entered as HTML on the page and returns a text that you can format as you like.


It should be used in this way:


<script type="text/javascript" src="/stats/top_pages.js.php?mode=1&pos=0&num=20"></script> 

This example returns top 20 titles. 



<li><script type="text/javascript" src="/stats/top_pages.js.php?mode=1&pos=0&num=1"></script></li>

<li><script type="text/javascript" src="/stats/top_pages.js.php?mode=1&pos=0&num=1"></script></li>

<li><script type="text/javascript" src="/stats/top_pages.js.php?mode=1&pos=0&num=1"></script></li>


This example shows top 3 titles as list. 


    mode = 0 : shows page title - default

    mode = 1 : shows page title and visits between ()

    mode = 2 : shows URL

    mode = 3 : shows URL and visits between ()

    link = 1 : text is hyperlink to its URL - default

    pos = N  : shows page at N position (0=first position, default)

    num = N  : shows first N pages - default=10 




Chart with latest visits 


By placing a simple string in your HTML page you can display a chart with received visits in recent days.

The most recent day (today) is on the far right of the curve.


The chart can be customized:


     days = N : shows latest N days     (default=7)

     mode = 0 : shows all    (default=0)

     mode = 1 : shows visited pages count

     mode = 2 : shows visitors count

     mode = 3 : shows returning visitors count

     width = N : chart width    (default=240)

     height = N : chart height    (default=120)

     title = tt : chart title    (default: none) 



    <script type="text/javascript" src="/stats/chart.js.php?days=30&mode=1"></script>

Chart of visits to a page 


This string will show a chart reporting visits from the page itself (or else, if specified) in the latest days.


The chart can be customized:


    page = P : page URL    (default: current url)

    width = N : chart width        (default=320)

    height = N : chart height    (default=240)

    title = tt : chart title    (default: none) 



    <script type="text/javascript" src="/stats/chart_page.js.php?width=240&height=128"></script>