We recently helped with a rather interesting project that involved switching between several regional websites based on the geographical location of the website visitor. The client, NY Headshots, wanted the ability to steer visitors from Mexico to their Mexico City based website, but also steer US clients to their New York based website if they happened to be on the Mexico City based version.
What they also wanted was a banner that would show up, and give the end user the ability to switch to the new website, or visit a dedicated page with a list of all the available locations – going forward the client wanted the ability to add new locations.
The designed region banner for implementation, showing instructions in Spanish
One of the challenges with this projects, and one we recognized from the beginning, was to make sure this was done in a way that would work with server level or application level caching. If you aren’t careful with an implementation like this, it’s quite easy to have WordPress cache the page of a visitor from Mexico, and then later show that page to a visitor from the US. Ultimately then the banner won’t reflect the actual location of the visitor, but rather the location of a previous visitor. So extra care had to be taken to make sure that the banner wouldn’t be cached.
While you can accomplish an implementation of this sorts by installing a local GeoIP database, it turned out the client was hosting their websites on Kinsta, and Kinsta supports GeoIP by request. Once we talked to them, they enabled various server-level headers that could be read by WordPress to determine the location of the website visitor. So while this could have been accomplished on another web hosting provider using a local database, having it handled by Kinsta helped save time on this project and made for a cleaner end-result.
We trust that this implementation will help steer potential customers to the most appropriate version of the website based on their region, and hopefully this will translate into less customer confusion and more revenue for our client. It was also interesting for us to experiment with the GeoIP abilities of the Kinsta platform – once again, they demonstrate why they are one of the premier WordPress hosting providers in the space.