Capture GEO Location on Form Entry Submission
In this guide, we will demonstrate how to capture GEO location with your form submissions.
1. Please create a new form or edit your existing form template:
2. Please add two Hidden fields on your form for the Latitude and Longitude fields.
3. Please add a JavaScript element on your form with the following code:
function get_geo_details() {
//Record Location
navigator.geolocation.getCurrentPosition( function(position){
//Set values
window.formyoula.form_fields["8570-e7c4-c1c6"] && window.formyoula.form_fields["8570-e7c4-c1c6"].set("value", position.coords.latitude);
window.formyoula.form_fields["9904-76e0-c28f"] && window.formyoula.form_fields["9904-76e0-c28f"].set("value", position.coords.longitude);
}, function(error){
//Record error if needed
}, {maximumAge:0, timeout:5000, enableHighAccuracy:true} );
}
//Check if GEO supported
if(navigator.geolocation && navigator.geolocation.getCurrentPosition){
//Get GEO
var set_interval_id = setInterval(get_geo_details, 5000);
}
//Remove set interval on form submit
$(".finish, .cancel, .draft").on("click",function(){
clearInterval(set_interval_id);
})
5. Please change the ID values in the JavaScript code with your merge field ID values:
6. Please Save & Close the form.
7. Now the GEO Location will be captured once you start a form entry (standard functionality) and once you submit it (custom functionality added by the steps on this guide). You can map these fields to your Salesforce records. And you can also view the GEO Location values on the CSV export file.
For any questions, please contact us - support@formyoula.com