Documentation

How to Create Google Maps API Keys for Gravity Geolocation

Last modified: September 20, 2026

Before You Begin

Gravity Geolocation requires two Google Maps Platform API keys: a Browser API Key for features that run in the visitor’s browser and a Server API Key for secure requests made by your WordPress site.

Create separate keys because each one needs different application restrictions. A browser key is visible in front-end page source by design, so it must be restricted to your websites. The server key should remain private and be restricted to the outbound public IP address or addresses used by your web server.

Create a Project and Enable Billing

1. Open the Google Cloud Console

Visit the Google Cloud Console and sign in with your Google account.


2. Select or Create a Project

  1. Use the project selector in the top navigation bar.
  2. Select an existing project or choose New Project.
  3. Enter a project name and create the project.

3. Enable Billing

Google Maps Platform requires an active billing account, even when your usage remains within Google’s no-cost usage thresholds.

  1. Confirm that the correct project is selected.
  2. Open Billing in the Google Cloud Console.
  3. Link an existing billing account or create a new one.
  4. Add or confirm a valid payment method.

Enable the Required Google Maps APIs

  1. In the Google Cloud Console, go to APIs & Services > Library.
  2. Search for each API your site needs.
  3. Open the API and click Enable.

Enable these APIs for Gravity Geolocation’s core map and location features:

  • Maps JavaScript API: Displays and controls interactive maps.
  • Places API (New): Powers current place and address autocomplete functionality.
  • Geocoding API: Converts addresses to coordinates and coordinates to addresses.

Enable these APIs when you use the related feature:

  • Routes API: Required for directions, distance, duration, and route-matrix calculations.
  • Address Validation API: Required when a form uses the Address Validation Field.
  • Maps Static API: Required when displaying static maps in entries, notifications, confirmations, or merge-tag output.

Do not enable Google’s Geolocation API for Gravity Geolocation. The plugin uses the visitor’s browser geolocation or the IP provider configured in the plugin settings for current-location detection.

Gravity Geolocation 3.5 API Requirements

Gravity Geolocation 3.5 uses Places API (New) for address autocomplete and Routes API for directions, distance, duration, and route-based travel calculations.

Version 3.5.1 includes temporary compatibility fallbacks for existing Address Autocomplete and Directions fields when a request fails because Places API (New) or Routes API is unavailable or blocked. The fallbacks do not cover every 3.5 feature and are not a substitute for enabling the current APIs.

For complete Gravity Geolocation 3.5 functionality:

  1. Enable Places API (New) in the Google Cloud project connected to Gravity Geolocation.
  2. Enable Routes API when using directions, distance, duration, or nearest-location travel calculations.
  3. Review the API restrictions on your Browser and Server API keys and allow the services used by each key.
  4. Confirm that both API keys are saved in the Gravity Geolocation settings.

If you upgraded from Gravity Geolocation 3.2.x and address suggestions or route calculations are not working, complete the steps above, wait several minutes for Google to apply the changes, clear any site or optimization cache, and test the form again.

If your existing Google Cloud project already has the legacy Places API or Directions API enabled, keep those services enabled temporarily while you transition. Gravity Geolocation 3.5.1 can use them only as compatibility fallbacks for existing Address Autocomplete and Directions fields. New Google Cloud projects may not offer legacy services, and other 3.5 features still require their documented current APIs.

Create the Browser API Key

1. Create the Key

  1. Go to APIs & Services > Credentials.
  2. Click Create Credentials > API Key.
  3. Copy the new key, then open its settings.
  4. Give the key a descriptive name such as Gravity Geolocation Browser.

2. Apply Website Restrictions

  1. Under Application restrictions, choose Websites or HTTP referrers (websites).
  2. Add every domain that loads Gravity Geolocation forms. For example: https://example.com/*.
  3. Add the www or non-www version, staging domain, and local development domain when those environments are used.

3. Apply API Restrictions

Choose Restrict key, then allow the browser-facing APIs used by your forms:

  • Maps JavaScript API
  • Geocoding API
  • Places API (New)
  • Routes API, when using directions, distance, or duration features in the browser
  • Address Validation API, when using the Address Validation Field
  • Maps Static API, when displaying static maps

If an existing Google Cloud project already uses Places API or Directions API, retain those services temporarily in the Browser key’s permitted APIs when relying on the 3.5.1 compatibility fallbacks. New projects should use Places API (New) and Routes API.

Save the key restrictions.

Create the Server API Key

1. Create a Separate Key

  1. Return to APIs & Services > Credentials.
  2. Click Create Credentials > API Key.
  3. Copy the new key and give it a name such as Gravity Geolocation Server.

2. Apply Server Restrictions

  1. Under Application restrictions, choose IP addresses.
  2. Add the public outbound IP address or addresses used by your WordPress server.
  3. Under API restrictions, choose Restrict key.
  4. Allow Geocoding API and Routes API.
  5. Save the key restrictions.

If you do not know the correct outbound IP address, ask your hosting provider. Some managed or cloud hosting environments use changing outbound IP addresses; confirm the supported restriction method before locking the key to an IP.

Important: Never place the Server API Key in front-end JavaScript or use an IP-restricted server key as the Browser API Key.

Add the Keys to Gravity Geolocation

  1. Sign in to your WordPress dashboard.
  2. Go to Forms > Settings > Gravity Geolocation.
  3. Paste the website-restricted key into Browser API Key (Required).
  4. Paste the private server key into Server API Key (Required).
  5. Click Save Settings.

Troubleshooting

  • Places API (New) permission errors: Confirm that Places API (New) is enabled in the same project as the Browser API Key and is permitted by that key’s API restrictions.
  • Routes API permission errors: Confirm that Routes API is enabled in the same project and permitted by the API key making the request.
  • Legacy fallback does not activate: The 3.5.1 fallbacks apply only to existing Address Autocomplete and Directions fields when the corresponding new API is unavailable or blocked. Confirm that the legacy Places API or Directions API remains enabled and permitted on the Browser API Key.
  • Billing errors: Confirm that the selected Google Cloud project is linked to an active billing account.
  • API not activated: Confirm that the error names an API enabled in the same project as the key.
  • Referer errors: Check the Browser API Key’s website restrictions and include the exact protocol and domain used by the page.
  • Server restriction errors: Confirm the public outbound IP address seen by Google, not only the IP displayed for your domain.
  • Recent changes: Wait a few minutes for new APIs or restrictions to take effect, clear site caches, and reload the page.
menu-circle