How to Create Google Maps API Keys for Gravity Geolocation
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
Enable the Required Google Maps APIs
- In the Google Cloud Console, go to APIs & Services > Library.
- Search for each API your site needs.
- 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
Create the Server API Key
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
- Sign in to your WordPress dashboard.
- Go to Forms > Settings > Gravity Geolocation.
- Paste the website-restricted key into Browser API Key (Required).
- Paste the private server key into Server API Key (Required).
- 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.
