Print

Connect to Google Search Index from Google Sheets

In this guide, we'll connect the Google Web Search Indexing API to Google Sheets, using the API Connector add-on for Sheets. This allows us to submit, update, and remove URLs from Google's search index directly from Google Sheets. API Connector doesn't have a native integration for this API so we'll set up a custom OAuth connection.

Contents

Before You Begin

Click here to install the API Connector add-on from the Google Marketplace.

Part 1: Set up Project

  1. Navigate to https://console.cloud.google.com/. To make things easier, set this up using the same Google account for which you log into Google Search Console. We're making a private app that can be accessed only by yourself.
  1. Click the project dropdown menu
    bigquery-img1
  2. Click New Project
    bigquery-img2
  3. Give it a name and click Create
    googlesearchindexing-create
  4. In your new project, navigate to APIs & Services > Library
    googlesearchindexing-library
  5. Search for "Web Search Indexing API" and click to open the details page
    Web Search Indexing API
  6. Click Enable
    googlesearchindexing-enableindexapi

Part 2: Get Credentials

  1. You'll now be back in your project. Click Create credentials (if you aren't on this page, click Enabled APIs & Services > Web Search Indexing API from the sidebar on the left)
    googlesearchindexing-createcredentials
  2. Fill out the Create Credentials form. It will take you through several sections, which you can fill out as follows:
    • Credential Type
      • Select an API: Web Search Indexing API
      • What data will you be accessing: User data
    • OAuth Consent Screen
      • App name: enter any name
      • User support email: select email address from the drop down menu
      • App logo: skip or upload a logo (optional)
      • Developer contact information: enter an email address
    • Scopes
      • Add or remove scopes:
        .../auth/indexing
    • OAuth Client ID
      • Application type: web application
      • Name: enter any name
      • Authorized redirect URL > + ADD URI: https://script.google.com/macros/d/12COOkin8nodCH7fZGIBu0D2jWY8-AEA0uvElt4Ph4wRbLUD4wslqQUfG/usercallback

  3. Click Create
  4. Once you've completed those steps, click Download to download your credentials and then click Done.
    googlesearchindexing-downloadcredentials

Part 3: Connect Google Search Index to API Connector

  1. Open up Google Sheets and click Extensions > API Connector > Manage Connections
  2. Scroll to the bottom of the sidebar and click Add Custom OAuth
  3. Fill in the Custom OAuth modal as follows:
    • OAuth Grant TypeAuthorization Code
    • NameCustom Index
    • Authorization Base URLhttps://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/indexing
    • Token URLhttps://oauth2.googleapis.com/token
    • Client IDprovided by Google in the credentials file
    • Client Secretprovided by Google in the credentials file
      googlesearchindexing-customoauth
  4. Click Save, then click back on Manage Connections
  5. You should now see your new Google Index connection listed. Click Connect.
    googlesearchindexing-customconnect
  6. You'll be prompted to log in and approve the connection. Click Allow.
    googlesearchindexing-allow
  7. You can verify that your connection is now active on the Manage Connections screen.

Part 4: Submit URLs to Search Index API through Sheets

We're ready! You can see all the available endpoints in the Google Search Indexing API documentation, but for this example we'll start with submitting a URL to be indexed. The syntax is the same whether this URL is new or simply being updated.

  1. Open up Google Sheets and click Extensions > API Connector > Open > Create request.
  2. In the request form enter the following, substituting in your own URL where it says your_url:
    • ApplicationCustom
    • MethodPOST
    • Request URLhttps://indexing.googleapis.com/v3/urlNotifications:publish
    • OAuth: Custom Index
    • Request Body (set to json): {"url":"your_url","type":"URL_UPDATED"}
  3. Create a new tab and click Set current to use that tab as your data destination.
  4. Name your request and click Run. A moment later you’ll see a message populate your Google Sheet
    googlesearchindexing-response

Note that this syntax works for just one URL at a time. API Connector doesn't support Google's batch index requirements, though you can cycle through a list of URLs using API Connector's multi-query functionality.

Part 5: API Documentation

Official API documentation: https://developers.google.com/search/apis/indexing-api/v3/using-api

Leave a Comment

Jump To