Before we start discussing the steps for creating a Search Console API report, we want to first discuss what it is, and why we need to use it.
Previously known as Webmaster tools, Google Search Console helps you understand how Google crawls, analyzes and indexes your website. It’s a great tool to help you discover problems which might hurt your rankings or user experience.
Search Analytics in the Search Console does not provide a report on how one dimension can impact another. You can get a query or page (landing page) report separately, but if you want to see which queries lead to which landing page you won’t be able to get it inside Search Analytics. It also doesn’t let you filter your reports by categories such as device or country.
To solve this issue, we will use the Search Console API to get dimensions and filtered data. Below are the steps on how to create the query and landing page report.
Step 1: Go to https://developers.google.com/apis-explorer/#p/, search for ‘search console’ in the search bar and click on ‘Search Console API’ (as highlighted below).
Step 2: After selecting Search Console API on the next page, select ‘webmasters.searchanalytics.query’ (highlighted in the screenshot below).
Step 3: Enter the URL of your site in the siteUrl section. In the request body section, add the start and end dates in YYYY-MM-DD format. The start and end date are required fields.
Then add the dimensions you want to get data for by clicking on the green plus sign under ‘dimensions’ section. Next, ‘add a property’ by using the drop down menu and then write ‘query’ and ‘page’. Click on the Execute button once the request body setup is complete.
Note: The sequence of the dimension fields is important, as the second field results are based on the first dimension field.
Step 4: Make sure you have completed the OAuth 2.0 authorization process. You can view whether you are authorized or not by searching for the ‘Authorize requests using OAuth 2.0: ON/OFF’ toggle in the top right corner of the query window.
In case the OAuth2.0 is set to OFF – click on the OFF section and a dialogue box will appear. After selecting the required scopes, click on Authorize.
Step 5: After completing the authorization and clicking on the Execute button, you will get a request and response code. With the help of JSON code in the response section, you can create CSV files by going to ‘https://konklone.io/json‘. Download and clean the CSV file per your requirements.
After converting the JSON code, the CSV file will look like this:
You can make the downloaded CSV file more report friendly by changing the heading of the report:
Other examples of the Search Console API requests
Example: To query the dimensions with filters of a particular country like ‘ind’ for India:
Example: To add a row limit to your request, click on the ‘Add a Property’ drop down menu, select ‘rowLimit’ and then specify the number of rows you want in the report.
Example: To add multiple filters you will need to define the starting row and row limit in the query.
In the screenshot below we have added two filters; one is related to the country, and the other is related to device type. We also added the start row and row limit to the request body. The start and end row fields are especially useful when you want to do batch processing of the report in batches of 5,000. By setting the startRow to 5,001 and the rowLimit to 5,000, you can get data for the next 5,000 rows and reach row number 10,000. The next request will start from 10,001.
Now you can create useful reports for the SEO team and help them with decision making. For more details on various other fields of the Search Console API, you can contact a Belo + Company expert or go to ‘https://developers.google.com/webmaster-tools/v3/searchanalytics/query’.