How can sites knows the country of users? a friend of mine asked me that question and that question drive us into long conversation about “Locating Positions of website’s user”. the idea is very simple behind how the sites locate users’ location. it is by IP address. these days there are many sites that can let you determine in which country a certain IP address, more over, it may give you a very accurate address. I’m usually using ip2location site but there are many websites that do the same job like geobytes and hostip.
Also there are some sites which selling database of IP addresses and locations but you need to keep updating your database every once awhile incase you decided to go with that