I decided that Google Analytics is not the best way to get around the exact numbers, since users who do not have JavaScript enabled in the browser will not be counted. Therefore, I would like to start creating my own Anylytics.
I have a table that will record the user's IP address, page URL and date / time.
Then I have a script that is at the bottom of each page of the site, which then runs an SQL query to send data to the database.
Here is the script.
$page_viewed = mysql_real_escape_string($_SERVER['REQUEST_URI']); if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip=$_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip=$_SERVER['REMOTE_ADDR']; } $ip = mysql_real_escape_string($ip); mysql_query("And then do the sql query.... ");
Since most of you here are experience developers, I want to know if you have any improvements in my scenarios or something that needs to be changed.
Frank source share