Connect Google Search Console and Analytics

Set up the Google OAuth client a self-hosted SEO Scaler deployment needs for Search Console and GA4.

Search Console and Google Analytics are optional. A self-hosted deployment needs its own Google OAuth client before either can connect. Both integrations share one client.

1. Enable the APIs

In the Google Cloud Console, create or pick a project and enable:

Under APIs & Services → OAuth consent screen, choose External and fill in the app details. While the app is in Testing, add every Google account that will connect as a test user.

3. Create the OAuth client

Under APIs & Services → Credentials, create an OAuth client ID of type Web application and add both redirect URIs for your deployment origin:

  • https://your-domain.com/api/gsc/oauth/callback
  • https://your-domain.com/api/ga4/oauth/callback

Scheme, host and port must match exactly, with no trailing slash.

4. Set environment variables

VariableValue
GOOGLE_CLIENT_IDClient ID from step 3
GOOGLE_CLIENT_SECRETClient secret from step 3
BETTER_AUTH_SECRETRandom string of at least 32 characters

Generate the secret with openssl rand -base64 32, then restart the deployment.

5. Connect

Open Integrations or Project settings, click Connect with Google, approve read-only access and pick the property for your project.

Troubleshooting

  • redirect_uri_mismatch: the redirect URI must equal your origin plus the callback path above.
  • "Google OAuth client not configured": one of the three variables is missing, or the secret is shorter than 32 characters.
  • access_denied: add the Google account as a test user on the consent screen.
  • No properties to pick: the account has no verified Search Console property or GA4 access.