Customer Experience Insights

Geolocation in the Magento checkout

Written by Christopher Liddell | May 13, 2022

For many years, the checkout process in e-commerce applications (particularly the shipping address) was relatively rudimentary, emphasizing the canonical structure American or European addresses, in which a ZIP code and a street or short descriptive address are usually enough to determine an approximate shipping cost. However, this has resulted in a drawback for those countries that have not structured their geopolitical partitions in the same way, or in other words, that do not use a postal code or street name in their address.

Some countries use provinces, cantons, districts, territories, towns, among many other divisions, but these divisions are becoming almost unnecessary today due to geolocation. In this article I'll be discussing about some of the challenges that exist in the shipping address at checkout, and how geolocation can help to solve them.

As already mentioned, not all countries have the same address structure, which may require customizations and programming efforts in your checkout page depending on the country in which you are operating, even more so if your business delivers to multiple countries, setting up a compatible checkout can be a complex task.

Fortunately, there is something that all countries and places in the world use to determine locations: geographic coordinates. Using latitude and longitude, it is possible to identify the exact delivery position, and with the use of services such as Google Maps or Open Street Maps, it is possible to obtain information about that point, such as the name of the street, the city, state, country and more. In this way, a nearly universal checkout can be designed, which can support the customer's address no matter where they are in the world.

Article of interest: Advanced Magento reporting

However, there are some challenges that come with using geolocation, particularly:

  • Usability (UI/UX):

Customers need to be able to easily use the geolocator, so the most important thing is to provide a map with a pointer, which they can move to select their exact delivery location. Behind the scenes, the map must convert the pointer into geographic coordinates, which will be used to estimate the shipping cost and available carriers.

It is important that the user is not forced to enter their coordinates manually, as this is terribly impractical and therefore leads to a bad user experience, so there must be a map or widget to select their location. An almost indispensable tool for this is the location search bar, which allows you to verbally write a location, for example "Miami", and then using geocoding (with services such as Google Maps or LocationIQ), convert it to a pair of latitude and longitude coordinates, eg: "Eiffel Tower" would be geocoded to "48.8583701, 2.2922926", then the map and your pointer should automatically move to that location.


The map must also be simple and easy to use, and it should fit appropriately in the screen, regardless of the device and resolution that the customer is using (laptops, tablets, mobile, etc).

  • Carrier integrations:


When using geolocation, the postal code, like other fields, is practically unnecessary in the checkout, since the coordinates can be used to determine the delivery point exactly, so it is recommended to even hide or remove superfluous fields in the checkout form, since it encumbers and delays the checkout process/experience.

The problem with removing standard address fields is that many shipping methods that work through an integration, such as DHL, Fedex, UPS, and USPS, typically use the zip code for shipping rates calculation. So, how do simplify the shipping address with geolocation without losing the functionality of shipping method integrations? The answer is: reverse geocoding, which works by taking a pair of coordinates, and using them to obtain geographic information such as street, city, postal code, etc. The same services that offer geocoding usually also offer reverse geocoding, in this way, you can have just the map at checkout, and from there derive the necessary information for integrations using reverse geocoding, without requiring the client to enter all the information manually. Remember the goal is to keep things simple for the customer; fewer steps, fewer problems.

  • Cost of geolocation services

    Maps, geocoding and reverse geocoding services work by invoking web services (using APIs), which usually have costs or restrictions depending on consumption, so it is important to consider the cost of using these services and measure it against the benefits they bring to your particular commerce (don't worry, they are reasonably priced).
    If you want to start using these features for free, you can use the services of Leaflet (which uses OpenStreetMaps) and LocationIQ, both are JavaScript libraries that allow you to perform a certain number of monthly API calls for free. The best known service -and possibly the most effective- is Google Maps, which has all the functionalities described so far, however, it requires you to input a credit/debit card just to request a license.

  • How do you add geolocation to your ecommerce?

    Magento does not include geolocation by default in its checkout, so you have to add it with an extension. You can contact us if you are interested in getting our geolocation extension for Magento2, which allows you to choose between different types of maps (Google or Leaflet), adjust the size and UI/UX settings, and also includes geocoding to convert written addresses to coordinates, and reverse geocoding to enable checkout integrations with shipping providers; as well as a "select my location" button, which uses the GPS of the customer's device to define its approximate coordinates and marks the pointer on the map to where they are.


It is becoming increasingly common to come across geolocation services, especially with the abundance of GPS devices and mobile applications, and even some delivery providers are requiring coordinates to operate, so it seems inevitable to have to update the traditional checkout to its modern version at some point, so we encourage you to take the lead with your business by using geolocation!