page loader

How To Display Visitor's Country On Your Website?

Display a visitor’s country on your website can make a visitor feel more at home and improve their browsing experience. As soon as the visitor sees their country name on your website for example in your websites headline or just a simple welcome message, it instantly grabs the visitor’s attention and builds trust. Display visitor country on your website is a great way to improve your website’s conversion rate as it adds a local touch.

Using Geolify you can easily get a visitor’s country and display it on your website with minimal amount of coding. Geolify utilizes a powerful and accurate IP to location service to extract the visitor’s country. Using Geolify’s Geo Javscript service, you can then display the visitor’s country directly on your website using a bit of javascript code. Below are the steps required to use Geolify to display visitor’s country on your website.

 

Step 1 : Sign up for Geolify

Sign up for Geolify, there is no credit card details required. You will get 1000 impressions for free to trial on sign up. Once you get the service working, you can purchase pre-paid impression packs to keep the service live. To provide accurate IP to location data, Geolify is a paid service. It is the only way we can maintain an accurate service.

 

geolify sign up

 

 

Step 2: Go to the ‘Javascript’ service

Click on the ‘Javascript’ button on the top to go to the Geo Javascript service page. The javascript service basically allows you to get visitor location information such as country, state and city directly on your website using a javascript function call. You will need this javascript service in order to get the visitor’s country name so you can display it on your website.

 

geo javascritp service

 

 

Step 3: Click the ‘Add New’ button

Click the ‘Add New’ button to create a new javascript service. You can create as many services as you want, there is no restriction. You may want to display visitor country on multiple websites, hence you will need to create multiple javascritp service as each service can only be used on a single domain. If you are a web design company and need to display visitor country information on various client websites, then Geolify is perfect as there is no restriction on the number of domains you can use our service on.

 

 

Step 4: Complete the Javascript service

Complete all fields in the javascript setup page. If you need help, there are instruction links provided for every field or you can find an overall instruction set by clicking on the blue instruction button on the top right hand side.

In the ‘Settings’ section you need to enter your ‘Usage Website URL’. This is the URL where you will be using this service. If you wan’t to make visitor location available throughout your website, then select the ‘Entire Website’  radio button for the ‘Usage Level’. If you just want to use this service in a specific page of your website, then enter the url for the page and select ‘Specified URL Only’.

You can also enter a ‘Default Country Text’ as a fall back if for some reason our service cannot determine the visitor’s country. It is always good to have a fall back country just so that you don’t get blank text on your website.

 

Complete geoliyf's geo javascript service

 

In the ‘Code’ section above, you will be provided with the ‘Website Code’. The ‘Website Code’ is the javascript function that will execute when a visitor visits your website. The ‘Website Code’ will get the visitor’s IP address, determine their location automatically and make the visitor’s country name available on your website in the form of a javscript function, in this case ‘geolify_country_name()’.

 

 

Step 5: Add ‘Website Code’ to your HTML HEAD

The ‘Website Code’  as mentioned is what extracts the visitor’s location for you and needs to be pasted in between your website’s HTML HEAD tags. An example is shown below.

Geolify Geo Javascript

 

 

Step 6: Add ‘geolify_country_name()’ to your HTML BODY

Now to display the visitor’s country on your website, you will have to run the country javascript function ‘geolify_country_name()’. You can see below how this function is used to display the test ‘Welcome visitor’s from [country]‘. The document.write script is a javscript function that outputs text onto your HTML page. You also need to remember to enclose everything in SCRIPT tags.

Geolify Geo Javascript

 

 

Conclusion

Display a visitor’s country on your website is very easy to do using Geolify’s Geo Javascript service. Geolify does all hard work of determining your visitor’s country accurately and provides neat javascript functions to make use of the visitor’s location information. Besides just displaying visitor country, you can also display the visitor state and city. You can also use these location javascript functions in multiple ways to create customized geo targeting experiences for your visitors. The other great thing with javascript is that it is compatible with almost all browsers including mobile browses so even if someone is using a mobile phone, Geolify’s services will work. Javscript is also compatible with almost all web page builders such as Joomla or WordPress.

 

GEOLIFY

#1 Geo Targeting SaaS

Geo Redirects

Geo Content

Geo Popups

Geo Images

Geo Notifications

Geo Links

Geo Javascript

Get Started For Free