PHP Page Hit Tracking Script

<<-back  |  continue->>

Step 2 - Install the PHP Files

Now we're ready to install the PHP files to let us view the stats from our new database table. If you haven't already, download all the necessary files from here...

Decompress the .SIT file and you should end up with a folder named "stats". Place this folder anywhere you want on the server you're tracking stats on. For this example, I'm going to put it in the root directory of my site. Now open this file for editing...

  • db.php

In the source code of this page, there should be a clearly marked section at the top for server-specific variables. These values will need to be set depending on what server you're using. The first variable...

localServer

...will need to have the value changed to the domain name of the site you're keeping stats for. This is to help determine which hits are from links inside the site, and which are from external referrals. When changing the values of any of these variables, just change the text between the double quotes to match how your server is set up. For the "$localServer" variable, do not enter the leading "http://www" for the web address.

The next list of variables hold the inforamtion necessary for PHP to communicate with the MySQL database. You'll need to get this information from your web host. A brief description of each variable is as follows...

  • $MPDB_database - the name of your database (not the name of the table)
  • $MPDB_hostname - the name of the database server (usually "localhost")
  • $MPDB_user - the MySQL username for your databse
  • $MPDB_password - the MySQL password for your database

If you've successfully made these settings and saved the file, we're ready upload the entire "stats" folder to your server and go on to the final step.

<<-back  |  continue->>