HACKER Q&A
📣 margal

How do Google/Facebook/Twitter/Netflix/Spotify determine my location?


I'm using my corporate gateway to access the web and our servers are located in Finland. A month ago, Google started to think I'm from Russia so suddenly my search results are in Russian. I've tried to submit to google that there are getting it wrong, no answer. I've searched the web, it seems like this is something a lot of people are experiencing and even they didn't got a response from google about it. I've tried to sample my IP in different services like IP2Location and MaxMind, all giving me the current location in Finland. I know I can specifically tell google my location but now I'm really trying to find out how each company determines my location. Any one knows?


  👤 jakub_g Accepted Answer ✓
1) For serving you a language version it's generally IP-based. The services like MaxMind update their DBs regularly because IP<>country assignments are not constant. (It's a bit of show in case of mobile IPs, like I'm in south of France and sometimes Google thinks I'm in Paris etc.).

Some users of those geoip services might have stale data if they don't update often.

I remember reading on HN about a guy from Switzerland whose IP is regularly changed in those DBs from "Switzerland, $French_speaking_region" to "Switzerland, $German_speaking_region" back and forth, so each month he sees local Swiss websites in a different language!

2) For getting your precise location, apart from GPS data, they also have a giant DB of wifi access points' names collected by passively sniffing wifis on a few billion Android devices (and other devices with Google software) all over the world; by intersecting this with names of wifis visible from your machine, they can assess your location even if your device has no GPS device built-in.

3) On mobile phones, your location is often taken based on the mobile network you're on. If you go abroad and connect in roaming, from network perspective you might be seen as being in the capital of your country, and have IP from your country, even if you're not there physically.

4) Some companies just use the CC number you signed with as the indicator of your country, regardless where you are physically.

TL;DR; it's a mess


👤 Jugurtha
Are you refering to search results or YouTube recommendations when logged out?

If you are signed in, YouTube recommends videos based mostly on your previous behavior.

If you're signed out, it's mostly based on what people in your location are watching.

In my case and in many others where I live, it's a fucking freak show. I seem to have nothing in common with these people. The signed-out recommendations are ugly and disgusting to me and people I know.

The search results are OK and in the language I search for mostly, except that the Wikipedia that is presented is not based on my browser/system languange (English) or the word I type, but it has started pushing Wikipedia in French, which I do speak, but not looking for as it's practically empty for topics of my interest.

I have to write "$word wikipedia English" or search "en." on the page and it's tiring.

Other sites ignore language and it's horrible. They present the Arabic version, which I also speak, that I'm not interested in. They don't even let me change that. It sucks and I stopped using these sites.


👤 getcrunk
It's been my experience, sometimes, that when using a VPN it almost seems like you are purposefully being misplaced. But by hanlons razor, maybe they use other metrics other than just IP to get a user's location, and that's what's messing things up.

👤 deepBDC
The core technology used by all the companies to determine location from IP address is called IP geolocation. The method of finding a location from IP address varies widely across IP geolocation service providers.

It is important to know how IP addresses are distributed and allocated across the globe in order to understand the challenges faced by IP geolocation services.

Under a global organisation IANA (Internet Assigned Numbers Authority), there are five regional internet registries that manage IP address distribution across the globe. For example, APNIC is responsible for managing IP addresses in Asia-Pacific region. This way, the entire block of 4.2 billion IPv4 addresses are distributed across the world like any other fixed resources.

When an ISP or organisations purchase a block of IP address from the respective regional internet registry, the details of the ownership of an IP address is registered in a publicly available database called WhoIS. And this database is commonly used by all the IP geolocation service providers. However, this is only one datapoint.

The key challenge of using only this database is that an IP address is rarely used in the region where it's ownership is registered. Often these IP addresses are not utilised in the same address where it is registered or they are resold to different organisation who may or may not be present in the same continent. These secondary transactions of IP addresses are not regularly updated on WhoIs database resulting in inaccurate information. Therefore, many sophisticated IP geolocation services like Maxmind, Digital Element and BigDataCloud go to a large extent to collect maximum ground-truth data about the IP address using various data collection methods (from users or network), partnerships and using AI/machine learning algorithms.

Hence, if you have access to global internet user base (like Google) you are more likely to present a more accurate IP geolocation service. Even then it is challenging to get accurate IP to location information because the ownership of IP address and its allocation frequently changes. Even while using an internet at home, your IP address is regularly refreshed by your local ISP. This is done by ISPs so that they can serve internet to the entire customer base. Remember that IP address is a finite resources. ISPs might have only few blocks of IP address which they need to dynamically allocate to their active customer base. This is more extreme in case of mobile network where it is possible for multiple users across the country to have a same IP address at some point of time. Therefore, location association of an IP address needs to be continuously updated.

The use of VPNs and proxies further complicate the matter. VPNs and Proxies mask your IP address and route your traffic from a different path making it difficult to for IP geolocation services. They might be able to detect that the connection is VPN but will not be able to identify the actual location of the user. This also happens in case of browsing the internet from your home when you are inside your company's VPN.

Besides IP address, companies can also find your location with the help of WiFi access point. For this, user needs to share their location and provide permission for browsers to scan your WiFi network. With the help of mass WiFi access point data collection, it is possible to have a database of location of WiFi Access point and using a trilateration or multilateration, the system can pin point your location. This will use the signal strength of surrounding WiFi access points. Similar to GPS technology used in mobile devices. This method has its own draw backs too. For example, if a user doesn't provide permission to track, it is impossible to locate his/her location. In case of areas where there are weak signal strength, the method will not be able to locate accurately.