How to detect user's location automatically and capture it in hidden field?

Hi all,

I am using gravity forms for collecting user details. I also want to collect the user’s state name and country without asking them to manually enter it. This data i want to capture in hidden fields and send it to salesforce.

As per the resources online I went ahead and installed these plugins-

  1. Geolocation IP Detection

  2. Geolocation Detector for Gravity Forms

after installing i am facing issues. I can now see “geolocation” in advanced fields but when dragged it in the form, I can not see any field settings for it. Nothing happens when I click on that field. Contacted author, no response.
image

Has anybody used this plugin ? or developed the feature from scratch using code?

Note: Since Gravity forms collects IP address i also looked if its possible to send it to SF directly and then SF can get the state and country name from it. But i have no knowledge in salesforce.
let me know which method is better here.

Any help is highly appreciated!

So, I have implemented a solution as when I was looking for something similar, I couldn’t find a plugin that seemed up to date. It’s a code snippet that fires after a entry has been saved, but before it gets sent to your CRM (in my case ActiveCampaign). I did it this way so that I wouldn’t have to pay for IP lookups every time someone went to a form… only when the form is saved.

Basically, I add “Administrative Only” fields to a form and then have them populated after making an API call.

Here’s my solution: wordpress-snippets/add_geolocation_to_form_entry.php at main · AJTatumDigital/wordpress-snippets · GitHub

Feel free to ask any questions or suggest any improvement!

4 Likes

thanks for solution! @ajtatum . this is exactly what i was looking for. I will implement this from my end and let you know if i have any questions.

1 Like

How will you deal with the applicable privacy laws with this data?

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.