I am trying to custom code a web page using Javascript(or anything needed), and use all information available to, with consent, find what country a person is in. I know there is geolocation, but that is longitude and latitude. I can track IP addresses too. I could use but not need something that can be used, like with onload.

I can do some custom coding to make it work, maybe something that gets a country code. I need some way to get country. For this, preferring geolocation to country somehow, but IP tracking may work. I would also like to know what sensors are being used. I know there is a country code of language, and I may use that, but I would like something else like my purpose is to limit countries I may sell or distribute to by WIPO Copyright Treaty.

I would prefer free, but I can do paid. I am trying in Javascript, I can use a system that allows such as is needed, I have not picked one yet but custom coding should be in it. Like only limits are that I can't afford a server so needs to be with a store platform, and must be a platform that can automate software selling. I may use like a client side script like Javascript as I can't find one that I can code back-end for.

I am trying to limit visitors to a web site to only be able to buy with location found and in specific countries, a subset of those with WIPO Copyright Treaty. I should also be able to use billing location tracking, but need geolocation or IP location country. I would have digital products and automated delivery. Just an idea, coordinates database, latitude and longitude, and a canvas element to find if a point is in a drawn shape, X E.

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Aug 6, 2023 at 0:12
  • I think I get the general gist of the question. Still, it would help if you could provide additional information, such as the software you're already using, how you intend to implement this and what precisely you intend to use or have used to implement this, for example, JavaScript/TypeScript/Node.js/Bun/Deno/Client-Side Script, etc.
    – Malekai
    Commented Aug 15, 2023 at 13:43
  • Please be specific if you need a client (javascript) or server (php, node.js etc) implementation. IP2Location.io has the free API but I will need to know which implementation you have decided for the sample codes.
    – Michael C.
    Commented Aug 18, 2023 at 6:35

2 Answers 2


This is not an answer but a general idea.

You probably need to buy a database that relates the geolocation to a geographical-political border.

I have not tried it, but here is one example of City-Location https://simplemaps.com/resources/free-country-cities

Here is the broader search: https://www.google.com/search?client=firefox-b-d&q=geolocation+to+country+database

They normally are for a Database, so CSV will be installed on a MySql and compared when the user request access or something.

There are also some databases for IP addresses.

Another option is a welcome screen so you ask for either the country code or the Zip number.

  • This answers like my question except geolocation API, IP and other found, but no like map like latitude and longitude found, geolocation was to not need to trust a customer, X E. Commented Aug 16, 2023 at 21:16

Have a look at the free GeoIP Database included in many Linux distributions:

apt info geoip-database  # or geoip-bin
Description: IP lookup command line tools that use the GeoIP library (country database)
 GeoIP is a C library that enables the user to find the country that any
 IP address or hostname originates from. It uses a file based database.
 This database simply contains IP blocks as keys, and countries as values and
 it should be more complete and accurate than using reverse DNS lookups.
 This package contains the free GeoLiteCountry database.

There is a lot of additional, related free software available in the Repositories.

For a commercial offering. the creators of GeoIP are: Maxmind.com

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.