Documentation

How to Create Google Maps API Keys for Gravity Geolocation

Last modified: September 11, 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.

Current version note: Gravity Geolocation 3.5 uses Places API (New) and Routes API. The legacy Places, Directions, and Distance Matrix APIs are not required for the current plugin version.

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.

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
  • 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

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

  • 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