Why do websites ask me where I'm from?

twitter logo github logo ・1 min read

Whenever I need to enter my address in a web-form, I always need to choose the country. It never defaults to the country I'm browsing from.
This always seemed weird to me as the advertisements and localized content always know where I'm from.

Why then don't websites use the same location & tracking info to make my job easier when filling forms?

twitter logo DISCUSS (5)
markdown guide

I think it's more or less because to know your country they need to interrogate a third party service (geolocalization service) to identify your country from your IP which could lead to false positives and slow down the serving of the webpage altogether.

In addition to that "the country you're from" might not be the country you're phisically in or you might be using a VPN.

So, to avoid all of that it's easier to ask.

Same reason why websites shouldn't decide which language to serve the content in solely based on the IP address.


I also don't know why this is the case. I would think that the Accept-Language HTTP header sent by the browser would be a good enough approximation for guessing the user's current country, at least as a convenience feature for pre-populating forms. It doesn't have to be spot-on.

The header contains one or more language codes (e.g. fr) and / or locale identifiers (e.g. en-US) in order of preference. So the first one should match closest the user's current country, if it's a full locale tag.

There's also an article about that header over at w3.org.

Since web development shifted heavily towards doing all sorts of magic right in the browser (such as form-processing and personalizing content based on user session) I can only imagine there are some problems with retrieving that locale tag from within JavaScript. The following StackOverflow discussion is hinting at that: stackoverflow.com/questions/104333...


If you are selecting it, it is your responsibility. Also it is easier to implement, and avoid the case where you are an expat or just travelling.
The ads probably get the data from the company you are filling out too, so it is a 2 way street. The ip-geo based is a fallback.

This would be a job for the browser auto-fill forms feature.


Websites don't do that because it costs money to implement and the majority of people aren't going to walk away from the form just because they had to select what country they are in. There would also be a small percentage of users who might be offended if you got it wrong.

on the other hand, ad platforms sell localized placement as a feature of their solution. so the cost of developing the solution is worth it.

I feel ya though, I too will find myself cursing that they aren't smarter; but there's also a line there. How would it make you feel if you came to my form and i pre-filled in your home address and phone number for you? email? last sites you visited? facebook login?

Maybe create a browser plugin to do it for you?


Thanks for all the replies :)
That's quite a few things I did not think of / did not know.

Classic DEV Post from May 2

The Art of Programming

One of the most consolidated misconceptions about programming, since the early days, is the idea that such activity is purely technical, completely exact in nature, like Math and Physics. Computation is exact, but programming is not.

Tamir Bahar profile image