Install googleAuthR from CRAN
install.packages("googleAuthR")
library(searchConsoleR)
Install searchConsoleR.
install.packages("searchConsoleR")
library(searchConsoleR)
Work flow always starts with authenticating with Google.
scr_auth()
Your browser window should open up and go through the Google sign in OAuth2 flow. Verify with a user that has Search Console access to the websites you want to work with.
Check out the documentation of any function for a guide on what else can be done.
?scr_auth
If it works, you should see a list of your websites in the Search Console via:
sc_websites <- list_websites()
sc_websites
We’ll need sc_websites$siteUrl
for the majority of the other functions.
Most people will find the search analytics most useful. All methods from the web interface are available. Here is an example query:
gbr_desktop_queries <-
search_analytics("http://example.com",
"2015-07-01", "2015-08-01",
c("query", "page"),
dimensionFilterExp = c("device==DESKTOP","country==GBR"),
searchType = "web", searchAppearance = "AMP_BLUE_LINKS",
aggregationType = "byPage", rowLimit = 100))
Filter your API results using this format: filter operator expression
Filter can be one of:
Operator can be one of ~~, ==, !~, !=
where the symbols mean:
~~
: ‘contains’,==
: ‘equals’,!~
: ‘notContains’,!=
: ‘notEquals’)Expression for page or query if freeform.
Expression for country must be the three letter country code as per the [the ISO 3166-1 alpha-3] standard. e.g. GBR
Expression for device must be one of:
Expression for searchAppearance must be one of:
You can have multiple AND filters by putting them in a character vector.
c("device==DESKTOP","country==GBR")
OR filters aren’t supported yet in the API.