page loader

How To Display Visitor's City On Your Website?

Displaying a visitor’s city name on websites is a widely used technique to show that your business is local and located near your visitors. Providing a local touch by showing the city the visitor is from is a great way to boost conversion rates and trust of your website. You might have already come across numerous dating advertisments around the internet showing ads such as ‘find singles in [your city]‘. How do they show such ads? It is a technique called geo targeting.

With Geolify you can seamlessly and accurately determine the city where the visitor is from and display it appropriately in your website with a minimal amount of coding. Geolify uses a powerful IP to location database and can extract a visitor’s location quickly making it available for use within your website via simple javascript functions.

Below is a step by step guide on how you can use Geolify to display a visitor’s city on your website


Step 1 : Sign up for Geolify

Sign up for Geolify, it is completely free to start a trial account with a 1000 impressions to get going. Once you are happy with the implementation you can purchase more impressions which can be used on all our services and for multiple domains making Geolify an excellent tool for web developers.


geolify sign up



Step 2: Go to the ‘Javascript’ service

To get the visitor’s city and make it available on your website, you will need to use Geolify’s Javascript service. Go ahead and click on the ‘Javascript’ button.


geo javascritp service



Step 3: Click the ‘Add New’ button

To create  a new Javascript service, click on the ‘Add New’ button. You can add as many services as you wish and for any number of domains. You will need to create a new service for each domain as a service can only be used for a single domain.



Step 4: Complete the Javascript service

Follow the instructions on the Javscript setup page and complete all fields correctly. If you need help, you can always click on the ‘instructions’ link next to each field to see how to complete it. There is also an overall instruction page which can be seen by clicking on the blue ‘Instructions’ button on the top right corner of the screen.

Don’t forget to fill in the ‘Default City’ field. This is used as a fall back incase for some reason Geolify cannot determine the visitor’s city. The fall back text will be displayed instead so that your web page text does not look blank.


how to display visitor's city on your website


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 city name available on your website in the form of a javscript function, in this case ‘geolify_city_name()’.



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

To obtain visitor city information throughout your website, paste the ‘Website Code’ in between your HTML HEAD tags. An example is shown below:



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

To display the visitor’s city name in your website as part of a full sentence, you will need to use the ‘geolify_city_name()’ javascript call in your website’s BODY. An example of how to write a sentence which includes the visitor’s city name is shown below.




Displaying a visitor’s city in your website for example in a headline or as a title is a great way to get attention. Website visitors are generally more attracted to something that is local or ‘around them’ as they feel it has some value to add. Geolify is an excellent easy to use tool to display a visitor’s city in any part of your website whether it is in a paragraph of text or a popup. Unlike other geo location services, you don’t need to download and install any complex IP to location database. Everything is handled by Geolify itself. Geolify is a fully managed service which makes it great to use if you are a web developer and need to provide location data to a number of client websites.





#1 Geo Targeting SaaS

Geo Redirects

Geo Content

Geo Popups

Geo Images

Geo Notifications

Geo Links

Geo Javascript

Get Started For Free