I don't trust any analytics or statcounter type websites I want to track my visitors by my own coding
can we track it by php or javascript if yes then how
I don't trust any analytics or statcounter type websites I want to track my visitors by my own coding
can we track it by php or javascript if yes then how
You can use $_SERVER["REMOTE_ADDR"]
to get the visitor's ip address. See http://www.php.net/manual/en/reserved.variables.server.php.
See $_SERVER['REMOTE_ADDR']
but given relative ease of use of HTTP proxies, you can't really trust it either.
You may want to use your webserver's logs, then, and generate reports with something like AWstats.
You can use $_SERVER to get the client's IP address. Based on it, you can roll out your own solution.
Alternatively, you can parse your visitor logs (apache logs for example).
However, tracking visitors is not a trivial task. Eventually, you will be looking at tracking repeat visitors, unique visitors, their demographic, their machine configuration and what not. Rolling out your own solution may just be re-inventing the wheel.
I think you cannot get it with javascript on client side. You have to execute ajax call on server and return IP from where request came to server.
You can check How to get client's IP address using javascript only?
I know you could use a PHP function like this:
function getRealIpAddr(){
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
//check if ip from share internet
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
//to check if ip is passed from proxy
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;
}
But.., take not that obviously if a visitor is using an anonymizing service, you can't grab any IP and never you can be 100% sure about real IP in any case.