This site uses cookies and other tracking technologies to make possible your usage of the website, assist with navigation and your ability to provide feedback, analyse your use of our products and services, assist with our promotional and marketing efforts, and provide better user experience.

By using the website, you agree to our Privacy policy

Accept and continue

Report a bug

Cancel
94
How-to 5 min read August 20, 2019

How to determine the user's city on the site

For commercial projects that offer different conditions of service depending on the region of the client, you need to implement the choice of the city on the site. The location of the user is determined by geolocation or check IP-address.

Why do you need to determine the location of the user

Adding the function of city selection to the site is needed on multiregional resources that provide different content depending on location:
Selecting city in the online store
Geolocation marketing is important for commercial sites that may have different service lists, prices and shipping costs depending on the region. Also, the user's location is necessary for information portals that provide a directory of local organizations and enterprises.

After selecting a city, the content change is implemented differently. On some sites, changing only the local phone numbers in the header, and on the other — the regional subdomain loaded by changing the city.

Such filtering helps to display not only the data for the entire region, but also to customize the content to a more precise location — the city area right up to the user's home, showing certain places nearby: for example, the store or office nearest to the customer.
Information about the location is provided only with the consent of the user, so you must first ask him to allow to determine geolocation.
How do websites determine location? If the user does not allow geolocation to be enabled in his browser, you need to determine the city by the visitor's IP address or display universal content without regional linkage. Checking the IP address may be inaccurate, so do not rely on it completely.
City auto-detection on the site
To implement the choice of the city on the site, you can use js-scripts, modules for the used CMS, API geolocation Google. Using the geolocation API will require programming skills: you need to configure error handling, set the location information update intervals, and if necessary, override the accuracy of the geolocation.

Google recommends you do not request information about the location of the visitor immediately upon loading, as the majority of users in such a situation will deny access to this data. You also need to explain exactly what location information is for.

How to add a city selection to a WordPress site

To set a visitor's location on WordPress, you can use the "Multi-City AV":
WordPress visitor location plugin
The plugin allows you to add shortcodes that give an opportunity to customize different content display depending on the client's location. When choosing a location, the base of cities is used.

The developer's site contains code snippets that must be added to the website to use this functionality.

To correctly configure the choice of the city on the website, you need knowledge in the field of web development. If not, you can get help from the developers.
select city in Multi-City AV plugin
The region is automatically determined from the list, and you can manually select another city. The system determines the latitude and longitude of the user's location, sets the country, region and city.

How to add a city choice to the OpenCart website

You can implement this functionality using the module "[OLD] Geo IP Tools".
IP city definition module for OpenCart
The tool is compatible with any version of OpenCart and performs the following functions:

  • allows you to determine the location by IP-address, also giving the opportunity to select the city manually;
  • when placing an order, information about the country and city is filled in automatically;
  • for different cities you can display different content;
  • You can set up a redirect, depending on the client's city, to the corresponding subdomain or URL;
  • there are bases with cities.

Example of the module:
geolocation module for OpenCart

Conclusion

Defining the client's city allows you to change the content of the site depending on the location of the user. At the same time, you can either replace individual elements, such as a phone number and address, or load a regional subdomain with completely changed information and design.

To implement the functionality manually, you need web development skills or specialist assistance. You can also find ready-made solutions for your CMS, which are easy to customize yourself.

This article is a part of Serpstat's Checklist tool
Checklist at Serpstat
Checklist is a ready-to-do list that helps to keep reporting of the work progress on a specific project. The tool contains templates with an extensive list of project development parameters where you can also add your own items and plans.
Try Checklist now

Learn how to get the most out of Serpstat

Want to get a personal demo, trial period or bunch of successful use cases?

Send a request and our expert will contact you ;)

Rate the article on a five-point scale

The article has already been rated by 0 people on average out of 5
Found an error? Select it and press Ctrl + Enter to tell us

Share this article with your friends

Sign In Free Sign Up

You’ve reached your query limit.

Or email
Forgot password?
Or email
Back To Login

Don’t worry! Just fill in your email and we’ll send over your password.

Are you sure?

Awesome!

To complete your registration you need to enter your phone number

Back

We sent confirmation code to your phone number

Your phone Resend code Queries left

Something went wrong.

Contact our support team
Or confirm the registration using the Telegram bot Follow this link
Please pick the project to work on

Personal demonstration

Serpstat is all about saving time, and we want to save yours! One of our specialists will contact you and discuss options going forward.

These may include a personal demonstration, a trial period, comprehensive training articles & webinar recordings, and custom advice from a Serpstat specialist. It is our goal to make you feel comfortable while using Serpstat.

Name

Email

Phone

We are glad of your comment
Upgrade your plan

Upgrade your plan

Export is not available for your account. Please upgrade to Lite or higher to get access to the tool. Learn more

Sign Up Free

Спасибо, мы с вами свяжемся в ближайшее время

Invite
View Editing

E-mail
Message
Optional
E-mail
Message
Optional

You have run out of limits

You have reached the limit for the number of created projects. You cannot create new projects unless you increase the limits or delete existing projects.

I want more limits