searchConsoleR (version 0.4.0)

search_analytics: Query search traffic keyword data


Download your Google SEO data.


search_analytics(siteURL, startDate = Sys.Date() - 93,
  endDate = Sys.Date() - 3, dimensions = NULL, searchType = c("web",
  "video", "image"), dimensionFilterExp = NULL,
  aggregationType = c("auto", "byPage", "byProperty"), rowLimit = 1000,
  prettyNames = TRUE, walk_data = c("byBatch", "byDate", "none"))



The URL of the website you have auth access to.


Start date of requested range, in YYYY-MM-DD.


End date of the requested date range, in YYYY-MM-DD.


Zero or more dimensions to group results by: "date", "country", "device", "page" , "query" or "searchAppearance"


Search type filter, default 'web'.


A character vector of expressions to filter. e.g. ("device==TABLET", "country~~GBR")


How data is aggregated.


How many rows to fetch. Ignored if walk_data is "byDate"


If TRUE, converts SO 3166-1 alpha-3 country code to full name and creates new column called countryName.


Make multiple API calls. One of ("byBatch","byDate","none")


A dataframe with columns in order of dimensions plus metrics, with attribute "aggregationType"


startDate: Start date of the requested date range, in YYYY-MM-DD format, in PST time (UTC - 8:00). Must be less than or equal to the end date. This value is included in the range.

endDate: End date of the requested date range, in YYYY-MM-DD format, in PST time (UTC - 8:00). Must be greater than or equal to the start date. This value is included in the range.

dimensions: [Optional] Zero or more dimensions to group results by.

  • 'date'

  • 'country'

  • 'device'

  • 'page'

  • 'query'

  • 'searchAppearance' (can only appear on its own)

The grouping dimension values are combined to create a unique key for each result row. If no dimensions are specified, all values will be combined into a single row. There is no limit to the number of dimensions that you can group by apart from searchAppearance can only be grouped alone. You cannot group by the same dimension twice.

Example: c('country', 'device')

dimensionFilterExp: Results are grouped in the order that you supply these dimensions. dimensionFilterExp expects a character vector of expressions in the form: ("device==TABLET", "country~~GBR", "dimension operator expression")

  • dimension

    • 'country'

    • 'device'

    • 'page'

    • 'query'

    • 'searchAppearance'

  • operator

    • '~~' meaning 'contains'

    • '==' meaning 'equals'

    • '!~' meaning 'notContains'

    • '!=' meaning 'notEquals

  • expression

    • country: an ISO 3166-1 alpha-3 country code.

    • device: 'DESKTOP','MOBILE','TABLET'.

    • page: not checked, a string in page URLs without hostname.

    • query: not checked, a string in keywords.

    • searchAppearance: 'AMP_BLUE_LINK', 'RICHCARD'

searchType: [Optional] The search type to filter for. Acceptable values are:

  • "web": [Default] Web search results

  • "image": Image search results

  • "video": Video search results

aggregationType: [Optional] How data is aggregated.

  • If aggregated by property, all data for the same property is aggregated;

  • If aggregated by page, all data is aggregated by canonical URI.

  • If you filter or group by page, choose auto; otherwise you can aggregate either by property or by page, depending on how you want your data calculated;

See the API documentation to learn how data is calculated differently by site versus by page. Note: If you group or filter by page, you cannot aggregate by property. If you specify any value other than auto, the aggregation type in the result will match the requested type, or if you request an invalid type, you will get an error. The API will never change your aggregation type if the requested type is invalid. Acceptable values are:

  • "auto": [Default] Let the service decide the appropriate aggregation type.

  • "byPage": Aggregate values by URI.

  • "byProperty": Aggregate values by property.

batchType: [Optional] Batching data into multiple API calls

  • byBatch Use the API call to batch

  • byData Runs a call over each day in the date range.

  • none No batching

See Also

Guide to Search Analytics: API docs:


Run this code
# }
   sc_websites <- list_websites()
   default_fetch <- search_analytics("")

   gbr_desktop_queries <-
                         start = "2016-01-01", end = "2016-03-01",
                         dimensions = c("query", "page"),
                         dimensionFilterExp = c("device==DESKTOP", "country==GBR"),
                         searchType = "web", rowLimit = 100)

   batching <-
                         start = "2016-01-01", end = "2016-03-01",
                         dimensions = c("query", "page", "date"),
                         searchType = "web", rowLimit = 100000,
                         walk_data = "byBatch")

# }

Run the code above in your browser using DataLab