Jump to content

I Need some help finding/writing a php script to track incoming hits from sites


Heath

Recommended Posts

I am looking to make or find some sort of referral script that will save the hits and domains that send my sites hits. I would like it to automatically store and display the top sites of the day and week and be able to embed the script easily in my current cms.

 

Any help would be greatly appreciated.  I've been looking for 2 days and can't seem to find any thing with a demo.

First I would try these search results:

 

http://www.google.com/search?hl=en&q=PHP%2FMySQL+Hit+Counter&btnG=Search

 

They will help you get started and then once you do that; then I would focus on getting the results for my CMS.

set up a table in your database, at a minimum it should have an auto incremental primary id column, a timestamp field and a column to put the referring url in.

 

then stick something like this at the top of every page you want to track

<?php

$referrer = $_SERVER['HTTP_REFERER'];

if($referrer != "" && $referrer != "your_domain.com"){
mysql_query("INSERT INTO tracking_table (referring_url) VALUES ('$referrer') ");
}

?>

 

wahlah, now you have a table filled links that linked to you site.  Then just write a script to query the table, based on your time stamp, to figure out the sites with the greatest hits.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.