Cloudways × Aelia Geo IP Location
If you run a professional WooCommerce store based on WordPress, you usually can’t avoid products from Aelia. Especially popular is the Currency Switcher and Tax Display by Country to comply with legal requirements as well as to improve the user experience. For many products, Aelia uses automatic location of the current user – based on the IP address.
However, new and innovative caching technologies, especially NGINX and Varnish Cache, make it difficult to dynamically locate the current user, as WordPress plugins cannot set preferences at the NGINX configuration level. So the location may work, but the cached content is output with the cached and presumably wrong location.
Providers such as Cloudways have recognized this fact and offer their own implementations for locating users. These are usually provided as headers and can be passed to the Aelia framework through a small implementation. This plugin takes care of this implementaion.
Functions and Necessity
The Aelia framework expects two-digit country codes to continue working with. Cloudways, on the other hand, outputs country names as written out text according to the ISO 3166 standard. This plugin translates the country coming from Cloudways into two-character country codes. A specific CSV file for ISO 3166 is used for this purpose.
The plugin is built with performance in mind. It’s very small and performant. At the same time, it’s easy to update country codes – even by yourself. Have a look at the FAQ for more information.
NGINX & Varnish Compatible
NGINX and Varnish are great caching approaches. This plugin supports them and makes Aelia products compatible with Cloudway’s implementation of geolocation feature.
Built for Cloudways
Cloudways is a great hosting provider with outstanding performance and options. They do also offer a geolocation feature which is taken into account for this plugin.
How-To: Installation & Configuration
The installation and configuration process consists of three steps. Please follow them accordingly.
Activate Geo IP on Cloudways
Log in to Cloudways and navigate to your application where you want to install the plugin. In the application settings, activate the “Geo IP” feature. After a few seconds, the configuration is complete and Cloudways provides information about the location of each visitor of the application (website) that uses this plugin.
Install & Activate Plugin
In the second step, navigate to your WordPress installation and install this plugin. Don’t forget to activate it as well, so that the geolocation information from Cloudways can be passed to the Aelia framework – translated by this plugin. Also make sure to have Aelia products installed.
Now empty the cache of your website. This works differently depending on the caching plugin. Test the functionality with different countries, e.g. through a VPN.
Questions & Answers
How can you use geolocation feature of Cloudways for Aelia products?
There are three easy steps: First, activate the Geo IP feature for the individual application on Cloudways. Second, install the WordPress Plugin. Third, clear cache and review carefully.
What about other hosting providers?
Does geolocation work with NGINX?
Yes, it does, but it depends on the individual implementation of the hosting company. Cloudways provides a Geo IP feature.
What happens if a country is not detected correctly?
Feel free to get in touch with me. I will add the country to the plugin and submit a new version. The general logic of the plugin is to first search for a match between the country name provided by Cloudways and the ISO 3166 country names. If there’s no match, it will look for a partly match. And if there is no partly match, the plugin will not provide any country code to Aelia and the Aelia logic will be responsible for getting the correct geolocation.
Can I add or change countries manually?
Sure thing. There is a csv file as a part of the plugin which contains the mapping between the country names and the country codes. Simply edit it, save it and there you go.
Are there any limitations?
This plugin is only designed for interaction between Cloudways and Aelia products. The source code can be viewed and customized for additional hosting providers.