Msg#: 3589737 posted 9:49 am on Mar 3, 2008 (gmt 0)
I would like to create a script that logs the following so I can track 'unique' visitors to each product page on my online store. I assume I would use unique IP to determine this?
id - auto inc page name - data generated from products page visitor ip - date / time of visit
I assume i need to do something like this:
// Check if visitor is already in the table for the certain page $ipaddress = $_SERVER['REMOTE_ADDR']; $visit_date = time(); $result = mysql_query("SELECT * FROM tracking WHERE ipaddress = '$ipaddress' AND pagename='$somepagename'");
How would I perform the rest of the query? Also it would be nice to allow a visitor to appear in the table again as a unique if he revisits after 1 week, is that possible?
Msg#: 3589737 posted 2:57 pm on Mar 3, 2008 (gmt 0)
You really can't. Not without the chance of banning an entire IP block in a sense because if somebody else ends up with that dynamic IP address, you potential are blocking any given user at any given time because you never know who is going to have that IP address next time around.
Msg#: 3589737 posted 9:22 pm on Mar 3, 2008 (gmt 0)
It would be better to use the session id.
I started with one written by someone called darklight - if you search for 'user tracker php script darklight' you'll run across it pretty quick. I've been using it for years with modifications along the way - looks like the author has put out a newer version than the one I have. When I downloaded it I had just barely started with php and didn't understand cookies at all. The script was well enough written that I could understand what was going on and modify to suit.