What is Geolocation?

Geolocation is the identification of the geographical position of a device in the real world, for example the computer connected to the internet with which you are reading this article; the more advanced version is based on GPS, but requires that the device is equipped with this technology and that the sharing of this data is activated by the same. In the case of a CMS like PrestaShop , the identification of the location of the connected device is based on IPs . This type of geolocation is used by the majority of services connected to the internet, such as Netflix, in order to provide a specific catalog for the country where the customer resides. Due to license and copyright limitations, not all films and series in the streaming platform catalog may be visible from Italy for example. Many users, thanks to streaming platforms, have discovered VPNs , in order to bypass geo-blocks and thus access films and television series not available in their country.

Statistical services, such as Google Analytics, use IP-based geolocation to identify the country from which a visit comes, accuracy depends a lot on the level of masking of the user's IP imposed by the GDPR. In fact, this system is a victim of the privacy phobia that pervades European regulations.

It is therefore good to say that geolocation is limited and regulated by the European directives and national regulations that have implemented them.

One of the most important rules concerning ecommerce is the prohibition of using geolocation to limit access to the catalog or to show different prices to countries belonging to the European Union . For example, if the visitor accesses our site from Poland, he / she must have access to the catalog without geographical limitations and the taxable amount of the products for sale, cannot be different from what we apply in Italy. Obviously it is possible to indicate different shipping costs and / or not to provide your own courier (in this case the customer will be responsible for sending his own courier to our warehouse to collect the ordered goods).

Why use Geolocation in PrestaShop?

Geolocation in an ecommerce can have different uses, the simplest, which can be activated in PrestaShop without additional modules, is to inhibit the display of the catalog or purchase in some countries. Obviously, as mentioned it cannot be done for those nations that are part of the European community. The reason for inhibiting access to certain countries may be the following :

  • Commercial reasons , by contract we cannot sell in certain countries or we do not want to compete with one of our resellers.
  • Political motivations , for example the current European sanctions on Russia. Or if our products are prohibited by the regulations of a particular country.
  • Ethical reasons , we do not want our products to be available in a country that does not respect the rights of an ethnic minority for example.
  • For security reasons , we do not sell for example in China and Russia, and considering that the majority of cyber attacks come from those two countries, we can decide not to give them access to our ecommerce. From this perspective, we can also exclude countries in which we do not intend to sell our products, even if only in order to save bandwidth and resources, as for example in the case of a pay-as-you-go CDN.

Geolocation can also be used to provide the customer with information, such as shipping costs and times in his country, without the need for him to register. In the case of PrestaShop, however, it is necessary to use third-party modules to have advanced features.

How accurate is Geolocation via IP?

Not much especially from free databases (such as the one provided by MaxMind and used by PrestaShop), it can happen for example that a user from Lugano (Switzerland) is located in Milan. This happens because the provider providing access to the Internet is the same and consequently the public IP of the connection is located in Italy, even if the connection comes from Switzerland. The difference in the geolocation database is precisely in the accuracy with which they are able to identify this type of situation. Generally, however, the free databases are able to correctly identify countries with few and rare errors, especially if we are talking about countries that are not members of the European community. If the user uses a VPN it will all be in vain.

How to activate the Geolocation in Prestashop?

As in previous versions of the CMS, to activate geolocation we go to Localization> Geolocation in our BO.

Prestashop in the latest versions 1.7 warns us:

From 30 December 2019, you need to register on MaxMind to obtain a license key in order to download the geolocation data. Once downloaded, extract the data using WinRAR or Gzip to the / app / Resources / geoip / directory

This applies to all PS 1.7 versions, you must therefore register on MaxMind in order to access the free database. Once registered and logged in, let's go to download files and download GeoLite2 City , let's not get confused with the CSV version.

Just unzip the downloaded ZIP file, and upload the GeoLite2-City.mmdb file to the folder via FTP / app / Resources / geoip / of our PrestaShop installation. Once this file has been uploaded, the CMS will be able to identify the geographical location by comparing the IPs contained in this DB with those of our visitors.

Once uploaded, we can enable geolocation in PrestaShop and decide how to behave and which countries can access our ecommerce.

To inhibit access to a country, just deselect it from the list in "Select the countries that can access your shop"

How to check the GeoIP settings?

To check the geolocation settings, we can use a VPN, locating with it in the country concerned. The test must be carried out with the browser with incognito navigation or different from the one normally used.

Visits arriving from disabled countries will receive a 403 error and will not have access to any part of our ecommerce. However, it is possible to inhibit only the purchase, by going from " Visitors cannot see your catalog ." to " Visitors can see your catalog but cannot place orders. "

There are many third-party modules that extend this functionality, most of them rely on this PrestaShop function, so it is necessary to enable the same, but some modules use subscription services, so it is good to always ask the developers how the location is identified connection. Geolocation is a powerful tool, but European directives and the GDPR have limited and made it more complex to use.

Author: Loris Modena


Per Ind Loris Modena , owner of Arte e Informatica , he began working in the IT sector in 1989 as a system engineer in charge of the maintenance and installation of IT systems. He started programming for the web in 1997 dealing with CGI programming in PERL and then moving on to programming in PHP and JavaScript. In this period he approaches the Open source world and the management of Linux servers.

PrestaShop Experts Program
PrestaShop Web Agency

Certified E-commerce Web Agency

Tecnoacquisti.com® is among the first Prestashop Platinum-certified agencies in Italy and in Europe. We specialize in helping small and medium-sized businesses sell online.

Consulting and Assistance

You can rely on our digital agency for advice or resolution of issues related to your online store or company website. 

Assistance | Check-UP | Hosting PrestaShop

Product added to wishlist