I don't think this is possible for OOTB geocodes
- Latitude and Longitude are geocode fields and meant to be derived using a service such as Data.com (from the Lead.Street, City, PostalCode, etc. fields)
- The Web-to-lead HTML generation doesn't enable these fields to be generated
- OOTB fields on W2L are referenced in the HTML by the API Name, not an Id yet when I try
<label for="latitude">Latitude</label><input id="latitude" maxlength="40" name="latitude" size="20" type="number" /><br>
the Latitude field is not populated in the resulting Lead
But for custom geocode fields, I created a field of type GeoCode Custom_Geocode__c
with 6 decimal precision (I did not use hours/minutes/seconds)
Then I went to the W2L HTML generation page /lead/leadcapture.jsp
and
- created HTML,
- saved into a file and then
- opened the file in the browser
- filled in the values (I used
56.7845
and 28.78661
)
- clicked Submit
Result, custom geocode fields were displayed in the page layout.
Here's the HTML from W2L
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">
<!-- ---------------------------------------------------------------------- -->
<!-- NOTE: Please add the following <FORM> element to your page. -->
<!-- ---------------------------------------------------------------------- -->
<form action="https://test.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">
<input type=hidden name="oid" value="00DXXXXXXXXXXXX">
<input type=hidden name="retURL" value="http://www.foo.com">
<!-- ---------------------------------------------------------------------- -->
<!-- NOTE: These fields are optional debugging elements. Please uncomment -->
<!-- these lines if you wish to test in debug mode. -->
<!-- <input type="hidden" name="debug" value=1> -->
<!-- <input type="hidden" name="debugEmail" -->
<!-- value="[email protected]"> -->
<!-- ---------------------------------------------------------------------- -->
<label for="first_name">First Name</label><input id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br>
<label for="last_name">Last Name</label><input id="last_name" maxlength="80" name="last_name" size="20" type="text" /><br>
<label for="email">Email</label><input id="email" maxlength="80" name="email" size="20" type="text" /><br>
<label for="company">Company</label><input id="company" maxlength="40" name="company" size="20" type="text" /><br>
<label for="city">City</label><input id="city" maxlength="40" name="city" size="20" type="text" /><br>
<label for="state">State/Province</label><input id="state" maxlength="20" name="state" size="20" type="text" /><br>
Custom Geocode (Latitude):<input id="0BC630000008YMf" name="0BC630000008YMf" size="20" type="text" /><br>
Custom Geocode (Longitude):<input id="0BC630000008YMg" name="0BC630000008YMg" size="20" type="text" /><br>
<input type="submit" name="submit">
</form>
Important - the Ids of these custom fields MAY/WILL NOT be the same when you deploy the fields to your Production or Staging org. You need to recreate the W2L form (or edit it) using the field ids of the custom fields per org
The custom geocode fields to be visible to the running user (via Profile or permission set) that executes the W2L process. See Web-to-Lead | Default Lead Creator