Configure Google Ads Keyword Planner for PagibleAI

Google Ads Keyword Planner supplies average monthly search volumes and related keyword ideas for PagibleAI. The admin AI chat and MCP clients use them to choose the keywords for titles, headings, texts and meta data. You can skip this setup if you do not need keyword research.

Get a developer token

  1. Create a Google Ads manager account if you do not have one. Google issues developer tokens only to manager accounts.
  2. Sign in to the manager account and open Admin > API Center.
  3. Complete the form and accept the terms to create the token.
  4. Apply for Basic access in the API Center and wait for Google's review.
  5. Copy the token to your deployment secret store.

A token with Test access works only with Google Ads test accounts, which return no real keyword data. Each deployment can share one token, but keep it on the server.

Find the customer IDs

  1. Choose the Google Ads account that sends the keyword planning requests. Use a regular advertiser account, not the manager account.
  2. Copy its 10-digit customer ID from the top of the Google Ads interface, e.g. 123-456-7890.
  3. If the OAuth user below gets access to this account only through your manager account, also copy the manager account's customer ID.

Dashes in the IDs are optional; PagibleAI removes them before sending the requests.

Create an OAuth client

  1. Open the Google Cloud Console and select the project for this site.
  2. Enable the Google Ads API under APIs & Services > Library.
  3. Open Google Auth Platform and set up the consent screen with an app name and support email.
  4. If the audience is External, publish the app so its status is In production.
  5. Create a client of type Web application under Google Auth Platform > Clients.
  6. Add https://developers.google.com/oauthplayground as an authorized redirect URI.
  7. Copy the client ID and client secret to your deployment secret store.

Refresh tokens of External apps in Testing status expire after seven days, so keyword research stops working a week after setup.

Generate a refresh token

  1. Open the OAuth 2.0 Playground.
  2. Select the gear icon, enable "Use your own OAuth credentials" and enter the client ID and secret.
  3. Enter https://www.googleapis.com/auth/adwords in "Input your own scopes" and select Authorize APIs.
  4. Sign in with a Google user who has access to the Google Ads account and allow access.
  5. Select "Exchange authorization code for tokens" and copy the refresh token.

PagibleAI acts as this user. Use an account that stays available, e.g. a dedicated user, because the token stops working when the user loses access to the Google Ads account or revokes the app.

Add the credentials to PagibleAI

Keyword research is part of the aimeos/pagible-metrics package, but the Google driver is not installed by default. Add it to your application first:

composer require aimeos/laravel-keywords-google

Select the Google driver (KEYWORDS_DRIVER is none by default) and add the values from the previous steps. Leave GOOGLEADS_LOGIN_CUSTOMER_ID empty if the user has direct access to the account. GOOGLEADS_VERSION is optional and sets the Google Ads API version (default v26):

KEYWORDS_DRIVER="google"

GOOGLEADS_CUSTOMER_ID="123-456-7890"
GOOGLEADS_LOGIN_CUSTOMER_ID=""
GOOGLEADS_DEVELOPER_TOKEN="..."
GOOGLEADS_CLIENT_ID="..."
GOOGLEADS_CLIENT_SECRET="..."
GOOGLEADS_REFRESH_TOKEN="..."
# GOOGLEADS_VERSION="v26"

Google allows one keyword planning request per second for each account. PagibleAI waits between requests across all PHP processes, so the Laravel cache store must support locks, e.g. database, file or redis.

Run the command below after editing .env, then restart Octane, queue workers and other long-running PHP processes.

php artisan config:clear

Test the keyword research

Sign in as a CMS user with page:metrics and page:chat permissions. Open the AI chat and ask for the monthly search volume of a common phrase, e.g. "headless cms" in the US, then for related keywords. The answer should contain volumes from Google Ads.

MCP clients can call the get-keyword-volume and get-related-keywords tools instead. Results are cached for seven days, so test a new keyword after changing the configuration.

Troubleshooting

Why does the log say “Google Ads setting [customer] is missing”?

KEYWORDS_DRIVER is google, but one of the required GOOGLEADS_* values is empty. Check the variable names, clear the configuration cache and restart long-running PHP processes. The setting name in the message tells you which value is missing.

Why does Google return DEVELOPER_TOKEN_NOT_APPROVED?

The developer token has only Test access but the customer ID belongs to a production account. Apply for Basic access in the API Center of the manager account.

Why does Google return USER_PERMISSION_DENIED?

The OAuth user cannot access the account directly. Set GOOGLEADS_LOGIN_CUSTOMER_ID to the manager account that links it, or give the user access to the Google Ads account and create a new refresh token.

Why does fetching the Google OAuth access token fail?

The refresh token has expired or was revoked, or it was created with a different OAuth client. Make sure the app is In production, generate a new refresh token with the same client ID and secret and deploy it.

Why are some search volumes empty?

Google has no data for rare keywords and rejects keywords with more than 80 characters or 10 words. Close variants like singular and plural forms share one volume.

What if the credentials were exposed?

Reset the client secret in Google Cloud, remove the app's access in the Google account of the OAuth user and reset the developer token in the API Center. Deploy the new values, clear the configuration cache and restart workers.