Monday, May 5. 2008
Posted by Jonathan Street
in Misc, PHP Programming, Website Management at
16:41
Comments (6)
Trackbacks (0)
Comments (6)
Trackbacks (0)
Pre-populating forms with the timezone
Following my initial discussion on using geo-targeting to predict timezones I've finally found time to play around with some of these ideas.
The idea
Simplify the user experience by predicting the timezone someone is in and auto-populating a registration form accordingly.
The solution
At the time I wasn't really looking for any solutions other than matching an IP address up to an actual location. This is certainly possible and I'll show you how below but first I'll highlight the alternative. If you are reasonably confident that the timezone will be set correctly on the users computer it is possible to access that value via javascript.
GeoIP to Timezone
If you want to avoid relying on javascript then you still have some options.
Maxmind: The PEAR pacakage supporting maxminds geoip databases doesn't support timezone lookup but the script offered by maxmind directly does support timezone lookup. The usage seems a little convoluted but it is there.
IP2Location: The timezone information is integrated directly in the database once you reach 'DB11', their 11th database offering. The usage should be straightforward. There is only one drawback - DB11 costs $649/year. Personally this is more than I would be willing to spend but their client list is impressive so if this is within your budget spread the moolah and use my affiliate link
.
Free solution: There are still a few options here. Although I haven't tried it I believe the maxmind code should work with their GeoLite products. Alternatively once you have a location, either using maxminds free databases or hostip.info you could try getting to a timezone using the 'world time engine' class available from phpclasses.org. The drawback with this approach is that even after the database lookup you still need to query two web services. That is going to introduce a significant lack in response time.
My preference
Although I started off looking at GeoIP services I would much prefer to be able to tackle this problem using javascript. It's not an ideal solution, some people will have their timezone set incorrectly while others will have javascript disabled but on balance I think it is good enough. This is the icing on the cake rather than core functionality after all.
The idea
Simplify the user experience by predicting the timezone someone is in and auto-populating a registration form accordingly.
The solution
At the time I wasn't really looking for any solutions other than matching an IP address up to an actual location. This is certainly possible and I'll show you how below but first I'll highlight the alternative. If you are reasonably confident that the timezone will be set correctly on the users computer it is possible to access that value via javascript.
GeoIP to Timezone
If you want to avoid relying on javascript then you still have some options.
Maxmind: The PEAR pacakage supporting maxminds geoip databases doesn't support timezone lookup but the script offered by maxmind directly does support timezone lookup. The usage seems a little convoluted but it is there.
IP2Location: The timezone information is integrated directly in the database once you reach 'DB11', their 11th database offering. The usage should be straightforward. There is only one drawback - DB11 costs $649/year. Personally this is more than I would be willing to spend but their client list is impressive so if this is within your budget spread the moolah and use my affiliate link
Free solution: There are still a few options here. Although I haven't tried it I believe the maxmind code should work with their GeoLite products. Alternatively once you have a location, either using maxminds free databases or hostip.info you could try getting to a timezone using the 'world time engine' class available from phpclasses.org. The drawback with this approach is that even after the database lookup you still need to query two web services. That is going to introduce a significant lack in response time.
My preference
Although I started off looking at GeoIP services I would much prefer to be able to tackle this problem using javascript. It's not an ideal solution, some people will have their timezone set incorrectly while others will have javascript disabled but on balance I think it is good enough. This is the icing on the cake rather than core functionality after all.
Thursday, May 1. 2008
Why don't geoip services accept feedback?
I've recently been playing around with geoip databases looking at implementing the type of timezone prediction I previously discussed. I'll be writing a blog post to cover that in the next week or so but first wanted to mention something which has been puzzling me.
Why don't geoip services accept feedback?
A good example of accepting feedback is Akismet. There you can report wrongly missed messages as spam and messages incorrectly labelled as spam as ham. I couldn't find an official statement on their accuracy but figures as high as 99.9% are mentioned. Defensio, a direct competitor, gives an accuracy rate of 99.77%. With my own experience using akismet an error rate of 1 in every 1000 seems about right.
In contrast, maxmind who is, to my knowledge, the commercial leader in geoip, states their accuracy as,
I don't have enough information to query their accuracy in the US but for the rest of the world it falls significantly from personal experience.
With feedback from their users I think this accuracy could be substantially increased.
Hostip.info
Hostip.info, which makes their database freely available does accept feedback from users. It's a simple process with only three screens and a CAPTCHA to get past. Oh, you also need cookies enabled. Not many people are going to use this. What is really needed is an automated process and this system is set up to prevent automated processes.
My 2 cents
Geoip services have the potential to more efficiently utilise their user communities than even the anti-spam services can. Internet users regularly submit their location on forums, social networks and whenever they make a purchase. These are all situations where predictions based on geoip lookups can create a more pleasant user experience. If the user doesn't change the predicted location then all is well. If the user does change the location though then that information should be sent back to the geoip service so the database can be updated.
Analysis of hostnames will only get you so far. To really boost the accuracy you need human reviewers. If you can convert ordinary internet users into reviewers without inconveniencing them then that's even better.
Why don't geoip services accept feedback?
A good example of accepting feedback is Akismet. There you can report wrongly missed messages as spam and messages incorrectly labelled as spam as ham. I couldn't find an official statement on their accuracy but figures as high as 99.9% are mentioned. Defensio, a direct competitor, gives an accuracy rate of 99.77%. With my own experience using akismet an error rate of 1 in every 1000 seems about right.
In contrast, maxmind who is, to my knowledge, the commercial leader in geoip, states their accuracy as,
Over 99% accurate on a country level, 90% accurate on a state level, 81% accurate for the US within a 25 mile radius.
I don't have enough information to query their accuracy in the US but for the rest of the world it falls significantly from personal experience.
With feedback from their users I think this accuracy could be substantially increased.
Hostip.info
Hostip.info, which makes their database freely available does accept feedback from users. It's a simple process with only three screens and a CAPTCHA to get past. Oh, you also need cookies enabled. Not many people are going to use this. What is really needed is an automated process and this system is set up to prevent automated processes.
My 2 cents
Geoip services have the potential to more efficiently utilise their user communities than even the anti-spam services can. Internet users regularly submit their location on forums, social networks and whenever they make a purchase. These are all situations where predictions based on geoip lookups can create a more pleasant user experience. If the user doesn't change the predicted location then all is well. If the user does change the location though then that information should be sent back to the geoip service so the database can be updated.
Analysis of hostnames will only get you so far. To really boost the accuracy you need human reviewers. If you can convert ordinary internet users into reviewers without inconveniencing them then that's even better.
