How to Install and Use the Geolocation Addon With WPForms

Would you like to learn more about the locations of the users who fill out your forms? With the WPForms Geolocation addon, you can easily collect geographical data for each of your leads.

In this article, we’ll show you how to install and use the Geolocation addon for WPForms.

Requirements: You will need a Pro license level or higher to access the Geolocation addon.


Setting Up the Geolocation Addon

Before getting started, you’ll first need to make sure that WPForms is installed and activated on your WordPress site.

Once you’ve installed WPForms and your license is verified, you’ll be able to quickly install and activate the Geolocation addon.

After you’ve activated the addon, you can configure its settings by going to WPForms » Settings and selecting the Geolocation tab.

Geolocation settings in WPForms

From here, you’ll have the option to choose which provider you’d like to receive your geolocation information in the Places Provider section.

Choose a places provider for Geolocation

Note: Selecting the None option from the Places Provider setting will not enable your forms to save location data.

Below, we’ve explained how to set up the Google Places API.

Google Places

Note: Google Places requires your site to have an SSL certificate (i.e., to load over HTTPS). If you’d like more information on how to get an SSL certificate for your site, be sure to check out WPBeginner’s guide on how to get a free SSL certificate.

Once you select the Google Places API option, additional settings will appear. First, if you would like to pre-fill your forms with users’ locations, check the Current Location box.

Allow users current location to be filled

Then you’ll need to retrieve your Google Places API key so you can enter it in the field provided. To do so, open Google Cloud Console in a new browser tab or window.

Generating Your Google Places API Key

At the top of your Google Cloud dashboard, select the project you’d like to enable this API key for from the Select a Project menu.

Select a project

If you haven’t previously created a project, click New Project to set one up.

Create new project

Note: Google will require you to enable billing on your account in order to use the Places feature. For more details on cost, be sure to check out Google’s pricing page.

Once you’ve opened up your project, you should be redirected to its APIs & Services dashboard. If not, open the hamburger menu in the top left corner of the screen and go to APIs & Services » Dashboard.

Then click + ENABLE APIS AND SERVICES.

Enable APIS and services

This will open the API Library. Search for and enable the following APIs:

  • Places API
  • Maps JavaScript API
  • Geocoding API

Note: Please be sure that you’ve enabled all 3 APIs, in order for this to work.

To enable an API for your project, all you need to do is click on the blue ENABLE button below its name.

Enabling the Google Places API

Once you’ve enabled the required APIs, navigate to APIs & Services » Credentials in the menu on the left. From here, click + CREATE CREDENTIALS and select the API key option to generate an API key.

Creating a new API key in Google Cloud

In the popup window with your new API key, click on RESTRICT KEY.

Opening the API restrictions settings

On the next screen, you’ll need to configure the following options:

Application Restrictions

To allow your API key to be used with WPForms, you’ll need to select the HTTP Referrers (web sites) option. This will allow your key to be used on websites.

Setting the API Restrictions to HTTP Referrers for a Google API key

Website Restrictions

Once you’ve allowed your key to be used on websites, it’s recommended that you restrict which domains are able to use it for security purposes. To do so, click on ADD AN ITEM in the Website restrictions section.

Adding a domain to a Google API key's website restrictions

Then enter your website’s domain in the field provided. If you’d like to allow your key to be used across an entire domain, enter it with a forward slash (/) followed by an asterisk (*) at the end.

Restricting a Google API key so it can be used across an entire domain

You can add as many items as you need to enable your key for your entire site or multiple sites.

Note: If your site uses subdomains, add *.example.com/* as an item in your website restrictions to enable your key to be used on all of your subdomains.

API Restrictions

Once you’ve restricted your key by Application and Website, you’ll need to restrict your key by API. To do this, select the Restrict key option.

Restrict API key

This will reveal a dropdown, from which you’ll need to select the specific APIs you’d like to restrict your key to.

Applications restrictions dropdown

From this dropdown, select the following APIs:

  • Places API
  • Maps JavaScript API
  • Geocoding API

Once you’ve selected these APIs, go ahead and click the Save button to save your settings.

Saving Google API restrictions

Copying Your Google Places API Key

After saving your settings, you’ll be redirected to an overview of all your available API keys. Go ahead and copy the value under the Key heading and return to your WPForms settings.

Back in your WPForms settings, paste the API Key you just copied into the API Key field and save your settings.

Adding Address Autocomplete to Your Forms

Once you’ve configured your Geolocation settings, you can enable the Geolocation addon’s autocomplete feature in your forms.

To do so, you’ll first need to create a new form or edit an existing one. Then, in the form builder, add either an Address field or a Single Line Text field.

If you’d like to display the address on multiple lines, select the Address field.

Adding an Address field to a form

If you’d prefer to display the address on a single line, choose the Single Line Text field.

Adding a Single Line Text field to a form

Then open the Field Options panel for your Address or Single Line Text field and click on the Advanced tab to open up additional settings. From here, you can turn on the address autocomplete feature by selecting the Enable Address Autocomplete option.

Enabling autocomplete for an Address field

If you’d like, you can also display an interactive map on the frontend of your site by selecting the Display Map option. This will reveal a dropdown where you can choose whether to show the map above or below your form’s field.

Enabling the map display for an Address field

Once you’ve got everything set up, be sure to save your form.

Here’s an example of how your form might look on the frontend with the map and address autocomplete options enabled:

Address autocomplete frontend example

Viewing Entry Location Data

To view an entry’s geolocation data, go to WPForms » Entries and choose the form you’d like to see geolocation details for. Then click View to open an individual entry’s page.

View individual entry page in WPForms

In addition to an interactive map, you’ll see details such as the user’s city, state, country, and zip code, as well as approximate latitude and longitude coordinates for the user’s town.

Geolocation Data in Entry

Including Geolocation Data in Form Notification Emails

If you’d like, you can also include geolocation data in automatic notification emails for your forms.

Note: For extremely large websites or those with a large volume of form submissions, it’s not recommended to include geolocation data in notification emails as it could impact server speed.

To set this up, open the form builder and go to Settings » Notifications. Then scroll to the Email Message section and add the {entry_geolocation} Smart Tag.

Add geolocation smart tag to notification email

Note: For more details on using entry data in your notifications, check out our tutorial on how to use Smart Tags in WPForms.

When the notification email is sent, it will include location data for the user.

WPForms Geolocation in notification email

Note: Geolocation data is stored in entries and can be displayed in notification emails. However, the {entry_geolocation} Smart Tag is not currently able to send information to third-party integrations such as Zapier.

That’s it! You now know how to collect geolocation data to learn more about your users.

Next, would you also like to send out different notification emails depending on users’ form selections? To learn how, be sure to check out our tutorial on conditional form notifications.