Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In web to lead, you can input any address that you want.I need to detect the exact location or just the state or city of the user who used the web to lead. Is this possible? any ideas how? Thanks in advance.

share|improve this question

If your browsers support Geolocation you will be able to get this information by adding simple JavaScript to your web to Lead form, otherwise you can simply click on the below link

Here is the link from very popular Google services

The JavaScript would be as below

  window.onload = function() {
  var startPos;
  var geoSuccess = function(position) {
  startPos = position;
  document.getElementById('startLat').innerHTML = startPos.coords.latitude;
  document.getElementById('startLon').innerHTML = startPos.coords.longitude;
share|improve this answer
thanks for the idea – gelay Jan 29 at 5:34

The other option is to fetch the public IP of user and from that IP figure out the location(approximate) of user.

Here is how you can find the users Public IP using javascript:

$.getJSON("", function (data) {
    alert("Your ip: " + data.ip);

Then use a free open source community that translate IP into location. geolocation ip service one such service that runs on the MaxMind database is available here:

share|improve this answer
Thanks @AtulRajguru9 for your idea. – gelay Jan 29 at 5:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.