How to display your visitors city name and use it to increase conversion

Have you ever seen content on a website so relevant that it felt like it was speaking directly to you? 

It is the most converting trend in the Digital Marketing space. It’s called Website personalization.

As a Web designer and Digital Marketer, I am always looking for better ways to market any business on the internet for myself and for my clients. Whether you run a blog or an eCommerce website or any business website on WordPress. Today I want to show you 2 easy ways to personalise your website depending on your visitors’ geolocation. That means you can offer discounts or delivery options based on your visitors’ location. This is marketing at its highest level. 

If you do not have a website check out my free course to create a website. Or if you want to start a blog, read this step by step guide to start a blog in South Africa.

The idea is to recognise that you understand the customer. Steve Jobs, one of the greatest Marketers once said “Get closer than ever to your customers. So close that you tell them what they need well before they realize it themselves.”

To understand what I want to show you let’s put this into perspective. What stands out better to you if you stay in Capetown and you visit a website that says “We deliver nationwide”. And you visit another website that says “We deliver in Capetown” or “This Item ships to Capetown”? 

Display Visitors city Name

Without thinking much, the website that identifies your location and offers something based on that is the winner. That is very powerful and converts extremely well.

Now let me show you how to display visitors city name in these 2 methods. The first method is free and the second method has more powerful features at a once off cost. What you choose is up to you. 

Method 1. Free custom code.

To display visitors city name, we will add a code snippet to your website. This code adds a custom function to your website that will connect to a free 3rd party database. If you are familiar with code you can add this to your child theme. But if you are not familiar with code I advise you to use the Code Snippets plugin as seen in the video. 

Copy the code below as it is and paste it in the Code Snippets Plugin.

function visitorcity_function() { 
$ip = $_SERVER["REMOTE_ADDR"]; 
$url = "http://geoip.nekoapi.icu/api/" . $ip; 
$json = wp_remote_fopen($url); 
$data = json_decode($json, TRUE); 
$city = print_r($data['city'], true); 
$result = $city; 
return $result; } 

add_shortcode('visitorcity', 'visitorcity_function'); 

add_filter( 'widget_text', 'shortcode_unautop' );
add_filter( 'widget_text', 'do_shortcode' );

After that you can place this shortcode anywhere you want to display the visitor’s city name. 

[visitorcity]

This Method is free but might not display the accurate location since some parts of the world do not have enough location data and your visitors Internet service provider (ISP) may have a generic IP address that might not display the accurate location data. 

Note

If you face an Error 500 Internal server error do not panic. Just contact your website hosting company and let them know that you are facing this error, they will fix it for you.

Method 2. Visitor City name plugin.

The second method to display visitors city name is using the If-so plugin. This plugin is so cool and does much more than displaying your visitors city name. The If-so plugin displays accurate location data and allows you to deliver dynamic content. 

The If-so plugin allows you to display dynamic content to site visitors based on “conditions” (or parameters), such as search terms, location, pages visited, or the number of visits.

Compatible with any page builder, If-So lets you customize any content on the page (even menu items) and allows you to create as many versions as you want.

Checkout the If-so plugin here.

There you have it. Choose a method that works best for you to display visitors city name

Leave a Comment

Your email address will not be published. Required fields are marked *