Configure SearchConsole

To allow PagibleAI to interact with Google Search Console and PageSpeed Insights (CrUX), you need to set up API access via a Service Account and then grant that service account permissions within your Search Console property.

1. Get Chrome UX Report (CrUX) API Key

To retrieve CrUX metrics, you need to obtain an API key from Google Cloud Console and enable the Chrome UX Report API for your project.

  • Go to Google Cloud Console: Navigate to https://console.cloud.google.com/
  • Create or Select a Project: From the top bar, select an existing project or create a new one.
  • Enable Chrome UX Report API:
    • In the navigation menu, go to APIs & Services > Library.
    • Search for "Chrome UX Report API" and enable it for your project.
  • Create API Key:
    • In the navigation menu, go to APIs & Services > Credentials.
    • Click "+ CREATE CREDENTIALS" and select "API key".
    • A new API key will be generated. Copy this key.
Google Cloud "Select a project" dialog displaying a recent project named "Aimeos". Google Cloud console with navigation menu open, displaying project ID "aimeos-376718" and a prompt to "Try Gemini Cloud Assist chat". A notification indicates "Now viewing project 'Aimeos' in organization 'No organization'". The Google Cloud API Library displays the search result for "Chrome UX Report API", a Google API providing real user experience data. Google Cloud's Chrome UX Report API details and overview. Google Cloud Platform API & Services Credentials management page, displaying API keys, an OAuth consent screen configuration reminder, and no OAuth 2.0 client IDs. Google Cloud API credentials management. Google Cloud console showing API key management with a "Create API key" dialog open, pre-filled with the name "PagibleAI CrUX", and initial application restriction set to "None".

2. Get Google Search Console API Key File

You will need to create a Service Account in Google Cloud and download its JSON key file.

  • Go to Google Cloud Console: Navigate to https://console.cloud.google.com/
  • Create or Select a Project: From the top bar, select an existing project or create a new one.
  • Enable Google Search Console API:
    • In the navigation menu, go to APIs & Services > Library.
    • Search for "Google Search Console API" and enable it for your project.
  • Create Service Account:
    • In the navigation menu, go to IAM & Admin > Service Accounts.
    • Click "+ CREATE SERVICE ACCOUNT".
    • Provide a Service account name (e.g., "PagibleAI-SearchConsole") and an optional description. Click "DONE".
  • Create and Download JSON Key:
    • Once the service account is created, click on its email address to view its details.
    • Go to the KEYS tab.
    • Click "ADD KEY" > "Create new key".
    • Select "JSON" as the key type and click "CREATE".
    • Your browser will download a JSON file (e.g., your-project-id-[hash].json). Save this file securely. This file contains your private key and is essential for API access.
Google Cloud "Select a project" dialog with "Aimeos" project listed. Google Cloud console with an open navigation menu, showing project details and a Gemini Cloud Assist chat prompt, along with a notification about the currently viewed project "Aimeos" within "No organization". Google Cloud API Library showing one result for "google search console api". Google Search Console API details on Google Cloud. Google Cloud console showing the Search Console API page with an enabled status, a navigation menu for IAM & Admin features, and additional API details like type, last update, and category. Google Cloud Platform's "Service accounts" page for the project "Aimeos," showing one enabled service account named "PagibleAI website" with its email, status, name, description, and key ID. Google Cloud service account creation details. Google Cloud Platform displaying details of the 'PagibleAI SearchConsole' service account, confirmed as enabled and recently created. Google Cloud console displaying the "Keys" tab for a service account, with warnings about key security risks and options to add new keys. Google Cloud dialog for creating a service account private key (JSON or P12), with a secure storage warning.

3. Configure Google Search Console for API Access

After creating the service account and downloading its key file, you must grant the service account access to your website's data in Google Search Console.

  • Copy Service Account Email: From the Google Cloud Console (IAM & Admin > Service Accounts), copy the email address of the service account you just created.
  • Go to Google Search Console: Navigate to https://search.google.com/search-console/
  • Select Your Property: Choose the website property you want to connect to PagibleAI.
  • Add User:
    • In the left sidebar, click "Settings".
    • Click "Users and permissions".
    • Click "ADD NEW USER".
    • Paste the service account email address into the "Email address" field.
    • For Permission, select "Restricted" (for read-only access).
    • Click "ADD".

Your service account now has the necessary permissions to access your Search Console data via API. Store the downloaded JSON key file in a secure location on your PagibleAI server.

Google Search Console overview for pagible.com, displaying search performance data including 3 total web search clicks. Google Search Console settings for pagible.com, showing ownership verification, user permissions, data export options, and robots.txt status. Google Search Console user permissions for pagible.com. Google Search Console user addition dialog.

4. Add to PagibleAI CMS

Once you have your CrUX API key and the Google Auth key file, you need to add it to your PagibleAI environment configuration:

CRUX_API_KEY="..."
GOOGLE_AUTH="..."

The value of GOOGLE_AUTH must be the string from the Service Account JSON key file encoded as base64. To do the encoding on the command line, use:

php -r 'echo base64_encode(file_get_contents("name-xxxxxxxxxxxx.json"));'