Search Console Setup
Configure Google Cloud so the plugin can securely access your Search Console data.
Already set up the GA plugin? If you've already configured a service account for the Google Analytics plugin, you can reuse the same credentials. Just make sure to enable the Search Console API and add the service account to your Search Console property (Steps 2 and 5 below).
Step 1: Create a Google Cloud Project
If you don't already have one, create a Google Cloud project:
Step 2: Enable the Search Console API
Important: Make sure you enable the Google Search Console API (also known as the Search Console API / Webmasters API), not the “Google Analytics Data API”.
Step 3: Create a Service Account
Skip this step if you already have a service account from the GA plugin setup.
Step 4: Generate a JSON Key
Skip this step if you already have a JSON key from the GA plugin setup.
The JSON key file contains the credentials you'll need:
{
"type": "service_account",
"project_id": "your-project-id",
"private_key_id": "abc123...",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEv...\n-----END PRIVATE KEY-----\n",
"client_email": "sanity-analytics@your-project.iam.gserviceaccount.com",
"client_id": "123456789",
...
}Step 5: Add Service Account to Search Console
Permission level: If you want to use the sitemap submit/re-submit feature from the dashboard, choose “Full” permission. For read-only access to search data, “Restricted” is sufficient.
Step 6: Set Environment Variables
Add these environment variables to your .env.local file in the web/frontend package:
# Service account credentials (same as GA plugin)
GA_SERVICE_ACCOUNT_EMAIL=sanity-analytics@your-project.iam.gserviceaccount.com
GA_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nMIIEv...\n-----END PRIVATE KEY-----\n"
# Search Console site URL (the property URL registered in Search Console)
SEARCH_CONSOLE_SITE_URL=https://your-website.comSEARCH_CONSOLE_SITE_URL must match exactly how your property appears in Search Console. For a URL prefix property, include the protocol (e.g., https://example.com). For a domain property, use sc-domain:example.com.
Next step: Now create the API route → so the dashboard can fetch Search Console data.