Wednesday, 11 February 2009

The Link Counter

This mini little collection of pages will allow you to track how many people come to your website and where from. It uses a basic amount of PHP and MySQL code and takes advantage of the $_GET array. Meaning that anylink is something like http://www.yourwebsite.com/?ref=theirwebsite.com

Installation

Installation of this mini set of code is very simple. As soon as you download edit "config.php" file so that the settings it asks for are filled in. And then upload all of the files to your website, then run the install.php script and then delete the file.

Now this is designed to go to your website and then forward to an actual area. Usually it is based that the user goes to the index file and then onto the actual website. But a lot of people have their website within their index.php/.html area anyway. But this is simply remedied, just rename the file to something else or stick it in a folder and then you can continue to use it.

If you renamed the file to link.php then your link is: http://www.yoursite.com/link.php?ref=theirsite.com

Or if you stuck it in a folder called link then it would be http://www.yoursite.com/link/?ref=theirsite.com.

Usage

You just need to make sure that the end part of the address is ?ref= and then their website address. The code will remove the http://www. from the address and then add it into the database.

Essentially everything website that links to your website needs to have the link updated. It does not detect it or add it if there is no "ref" variable. It will just forward it to the website.

Viewing Your Stats

If you have php my admin then you can use that to read the stats but the script comes with a file called "stats.php" which allows you to view a list, in order of most clicked of all the people link to your website.

Bug Reporting and Suggestions

If you find that you are having some trouble with the code or you have some improvement ideas then comment in the area below and i will see what the problem is an attempt to fix it.

0 comments: