Google Search Console

Details an integration available for Google Search Console, built and maintained by Umbraco HQ.

This integration provides an extension for Umbraco CMS. It provides details on indexed URLs managed in Google Search Console.

Minimum version requirements

Umbraco CMS

MajorMinor/Patch

Version 8

8.4.0

Version 9

9.0.1

Version 10

10.0.0

Version 11

11.0.0

Authentication

The package uses the OAuth2 security protocol for authentication. After the authorization process completes successfully, the access token and the refresh token will be saved into the Umbraco database.

All requests to the Google Search Console API will include the access token in the authorization header.

Self Hosted OAuth Configuration

The easiest way to configure the integration is to make use of an application Umbraco has pre-configured with Google. With this in place, the authorization flow will go through a proxy website Umbraco maintains before redirecting back to your Umbraco backoffice.

From version 1.1.0, we introduced an alternate approach that requires a little more setup. It removes the need for relying on any services from Umbraco when using the integration.

To use this you need to setup your own app with Google and use an extended configuration like this:

appsettings.json
"Umbraco": {
  "CMS": {
    "Integrations": {
      "SEO": {
        "GoogleSearchConsole": {
          "Settings": {
            ...
            "UseUmbracoAuthorization": true/false
          },
          "OAuthSettings": {
              "ClientId": "[your client id]",
              "ClientSecret": "[your client secret]",
              "RedirectUri": "https://[your website base URL]/umbraco/api/googlesearchconsoleauthorization/oauth",
              "TokenEndpoint": "[google token endpoint]",
              "Scopes": "https://www.googleapis.com/auth/webmasters https://www.googleapis.com/auth/webmasters.readonly"
            }
        }
      }
    }
  }
}

The authorization mode is toggled by the UseUmbracoAuthorization flag, which by default is set to true meaning that previous versions are not impacted.

Authorization specific methods are exposed by the IGoogleAuthorizationService and implemented by two services:

The used service is provided using the AuthorizationImplementationFactory method, depending on the type of authorization selected.

If you are selecting your own authorization flow that uses the AuthorizationService, the redirect URL will be this one: /umbraco/api/Googleauthorization/oauth, from GoogleAuthorizationController. Make sure to set to correct URL in the settings of the website and in the configuration of your Google app.

The authorization controller uses the window.postMessage interface for cross-window communications when redirecting from the Google Search Console authorization server.

Working With the URL Inspection Tool

The URL Inspection Tool is accessible from each content node via the URL Inspection content app.

If you haven't connected your Google account yet, you can authorize your Umbraco application by using the Connect button. This will prompt the Google authorization window and at the end of the process, you will receive the access token and the refresh token.

You can also choose to remove access to Google Search Console API by triggering the Revoke action. This will remove the access token and the refresh token from the database.

Before you can retrieve data from the Search Console API you need to register the domain of your Umbraco website. This is done at the Google Search Console.

After Google has verified your ownership, the URL Inspection tool will provide the proper results. Otherwise, a "permission denied" error will be shown.

The URL Inspection Tool API

The URL Inspection Tool API expects three parameters, two mandatory:

  • InspectionUrl - a fully-qualified URL to inspect. It must be under the property specified in "siteUrl".

  • SiteUrl - the URL of the property as defined in the Search Console.

  • LanguageCode - optional; the default value is "en-US".

More information can be found in the official Google Developers documentation.

Last updated