Forum Moderators: coopster
I've got a requirement from a client about tracking. What I would like to do is when someone clicks on a button, I want to track that click in place that into the DB.
Essentially when you do click on the button a JavaScript window opens which is called contact.html for example.
Any good ways of overcoming this?
Thanks
click on the button, and instead of opening "contact.html", open "tracker.php?goto=contact.html"
the file "tracker.php" contains some SQL commands that writes to the database, but has no output and just passes the person along with header():
$query="INSERT INTO mytable (URL,Datetime) VALUES ($HTTP_GET_VARS['goto'],date("Y-m-d h:i:s",mktime()))";
mysql_query($query);
header('Location:'.$HTTP_GET_VARS['goto']);
You can also store the Referrer page, the remote_address (user IP), and any other statistics about the situation that your server can see and you might be curious about. The table then contains a record of each click, with the date/time, what page the person was clicking to, etc. The one table can be used to track clicks to any number of pages, and the statistics can be gleaned with a simple SQL SELECT.
Good luck!
Instead, I prefer the data type "datetime", where I explicitly write the date and time in format
YYYY-mm-dd hh:mm:ss
I feel like it gives me more control, and it behaves just like a string, in an obvious predictable way.
You don't have to change the SQL INSERT command, as long as the field is there in the Table you're OK.