When I create a URL to a specific Amazon product, the URL needs to include the proper Amazon site specific to the visitor's country.

So I need to geocode the visitors location, then map that geocode to the proper Amazon store.

I suspect that I am not the first to need this. There are universal URL generator sites, but I don't want to use their domains in the URL - and I want to include my affiliate code, not theirs.

So, looking for code that I can modify to map a visitor's geolocation to the proper Amazon store. The code should figure out the proper Amazon URL for the visitor's country (like amazon.ca or amazon.de, etc).

Looking for server-side code so I don't have to worry about ad-blocking; PHP language preferred.


1 Answer 1


I found information about the Amazon sites that are assigned to each country here: https://www.amazon.com/gp/help/customer/display.html/ref=help_search_1-2?ie=UTF8&nodeId=201357480&qid=1567291843&sr=1-2

So all that is needed is to use geolocation code to determine the country code from the visitors IP address. Once that country code is found, you can use the above information to determine the correct Amazon 'store' for that visitor's country.

There are several (many) geolocation services that will use CURL or other methods to determine the country code of an IP address.

By using the information in the link, and a gelocation service, code can determine the proper Amazon store for the visitor. (I built my own code to do that, but that code is outside the scope of this question.)

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.