Query search traffic keyword data

Description

Download your Google SEO data.

Usage

1
2
3
4
5
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"))

Arguments

siteURL

The URL of the website you have auth access to.

startDate

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

endDate

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

dimensions

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

searchType

Search type filter, default 'web'.

dimensionFilterExp

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

aggregationType

How data is aggregated.

rowLimit

How many rows, maximum is 5000.

prettyNames

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

walk_data

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

Details

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'

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, but 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'

  • 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.

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

Value

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

See Also

Guide to Search Analytics: https://support.google.com/webmasters/answer/6155685 API docs: https://developers.google.com/webmaster-tools/v3/searchanalytics/query

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Not run: 
 
   library(searchConsoleR)
   scr_auth()
   sc_websites <- list_websites()
   
   gbr_desktop_queries <- 
       search_analytics("http://www.example.com",
                         start = "2016-01-01", end = "2016-03-01",
                         dimensions = c("query", "page"),
                         dimensionsFilterExp = c("device==DESKTOP", "country==GBR"),
                         searchType = "web", rowLimit = 100)
                         
   batching <- 
        search_analytics("http://www.example.com",
                         start = "2016-01-01", end = "2016-03-01",
                         dimensions = c("query", "page", "date"),
                         searchType = "web", rowLimit = 100000,
                         walk_data = "byBatch") 
  
  
## End(Not run)