I'm trying to make a browser tracking for my website, so far it is going good. But when i came to Google Chrome it just say i'm in Chrome 20.x. When i look i'm in Chrome 23.x.
I have IE 8 and the code is as followed:
else if (ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) {
$browser_version = $log_version[1];
$browser_name = "IE";
$browser = $browser_name ." ".$browser_version;}
And for my Google Chrome tracker:
else if (ereg('Chrome ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) {
$browser_version = $log_version[1];
$browser_name = "Google Chrome";
$browser = $browser_name ." ".$browser_version;}
After the code it goes to my MySQL but if you try it you can simply echo the code.
How do I make it track the right browser version, and what is it i did wrong?
Looking at my user-agent for Chrome, it is formatted like this: Chrome/23.0.1271.64
Hence, you would have to change your Chrome regex from:
Chrome ([0-9].[0-9]{1,2})
to
Chrome/([0-9]{1,2}.[0-9]{1,2})