To detect visitor's location, you need two things
1. The Geolocation API
2. IP Address Lookup
Read the detailed article here.