Google Search Console
Reads searches, clicks and indexing; resubmits sitemaps
- You make
- a service account's key file (the same one as for Google Analytics will do)
- Where
- https://console.cloud.google.com/iam-admin/serviceaccounts/create
- Command
kokuban connect gsc --key-file <file.json> --account <https://example.com/ or sc-domain:example.com>
Steps
- Pick or make a Google Cloud project, and turn on the Google Search Console APIIn the console's API Library, search for Google Search Console API and press Enable.
- Make a service account named kokuban (no roles needed), then Keys, Add key, JSON
- In Search Console: Settings, Users and permissions, Add user: the service account's addressThe service account's address ends in .iam.gserviceaccount.com. kokuban prints it when you connect.
- Restricted is enough to read; Full also lets it resubmit sitemapsSearch Console has no API to ask for indexing of ordinary pages; resubmitting the sitemap is how kokuban tells it about new pages.
Then connect it
kokuban connect gsc --key-file <file.json> --account <https://example.com/ or sc-domain:example.com>kokuban asks for the key (it is not shown as you paste it), keeps it in your OS keychain, and tries it at once. If the key cannot do something, it says what to change.
On kokuban's screen, the connections list shows the services not connected yet: open one and press y, and the screen hands the terminal to this command.
Good to know
- --account is the site as Search Console writes it: https://example.com/ for a URL-prefix property, sc-domain:example.com for a domain property.
- The same key file as for Google Analytics will do.
If it does not work
In Search Console, add the service account's address as a user of this site (Full to resubmit sitemaps)
kokuban connections checks every connection and says which ones need you.
Taking it back
Run kokuban disconnect gsc@hq, remove the user in Search Console's Users and permissions, and delete the key in the Google Cloud console.