zesty.io

Product

Use Cases

Integrations

Learn

How to Personalize User Experience by Accessing Geolocation

If a user's browser has access to the W3C Geoloction API, you can learn the latitude and longitude of a user through a couple simple Javascript function. This article gives you the example functions,

Browser Compatibility

The Geolocation API works on the following browser versions and all of their successor editions: Firefox 3.5, Google Chrome, Opera 10.6, Internet Explorer 9.0, and Safari 5.

Setting up the Javascript

Put this javascript into your main.js or inline on page in <script> tags, save, and open your site preview.

Accessing Latitude and Longitude

To test the script above is working, open your browser developer console and type geoFindMe(); and hit return. If the above script was installed correctly, your browser should prompt you for permission to access your location. Allow permission. After allowing permission you should see a popup dialog box with your latitude and longitude.

The success() function shows you how to access the latitude and longitude values from the position object. Write your custom scripts in there and have fun!

Start Here

We will listen to your needs and walk you through how Zesty can help your team.

Connect with Content Experts

Book a free 15-minute consultation with a content expert. Discuss your application, pain points and requirements. Understand how Zesty's lower total cost of ownership, features, functionality can elevate your business by creating extraordinary digital experiences.

Trusted By

zesty customer logo Sonyzesty customer logo Rocket Leaguezesty customer logo Singlifezesty customer logo Acornszesty customer logo Phoenix Sunszesty customer logo Wattpadzesty customer logo Corner Shopzesty customer logo Bjs

G2 MOMENTUM LEADER

zesty customer logo zesty customer logo zesty customer logo zesty customer logo

Enter your details to connect with a Content Expert

First Name

Last Name

Email

Phone (optional)

Company

Please tell us about your project (optional)