This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hostname ="https:example.ru:443" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
site_url = "https://example.ru" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query <- "https://api.webmaster.yandex.net/v3/user/" | |
get_user_id<-GET(url=query, add_headers(Authorization="СЮДА НУЖНО ПРОПИСАТЬ ПОЛУЧЕННЫЙ ТОКЕН")) | |
user_id = fromJSON(content(get_user_id,type="text")) | |
user_id = user_id$user_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query <- paste("https://api.webmaster.yandex.net/v3/user/", | |
user_id, | |
"/hosts/", | |
hostname, | |
"/search-queries/popular/?order_by=TOTAL_CLICKS&query_indicator=TOTAL_CLICKS&query_indicator=TOTAL_SHOWS", | |
sep = "") | |
getdata <-GET(url=query, add_headers(Authorization="СЮДА НУЖНО ПРОПИСАТЬ ПОЛУЧЕННЫЙ ТОКЕН")) | |
json_file = fromJSON(content(getdata,type="text")) | |
json_file1 = jsonlite:::simplify(json_file, simplifyDataFrame = TRUE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brand_q = as.data.frame(popular_q_file[grepl("бренд|brand",popular_q_file$query_text),]) | |
names(brand_q) = c("query", "shows", "clicks") | |
brand_ctr = data.frame(sum(brand_q$shows), sum(brand_q$clicks)) | |
names(brand_ctr) <- c("Shows", "Clicks") | |
non_brand_q = as.data.frame(popular_q_file[-grep("бренд|brand",popular_q_file$query_text),]) | |
names(non_brand_q) = c("query", "shows", "clicks") | |
non_brand_ctr = data.frame(sum(non_brand_q$shows), sum(non_brand_q$clicks)) | |
names(non_brand_ctr) <- c("Shows", "Clicks") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start = json_file1$date_from | |
end = json_file1$date_to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data_gsc <- search_analytics(siteURL = site_url, | |
startDate = start, | |
endDate = end, | |
dimensions = c('query'), | |
searchType = c('web'), | |
rowLimit = 25000, | |
walk_data = 'none') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
google_brand_q = as.data.frame(data_gsc[grep("бренд|brand", data_gsc$query),]) | |
g_brand_ctr = data.frame(sum(google_brand_q$impressions), sum(google_brand_q$clicks)) | |
names(g_brand_ctr) <- c("Shows", "Clicks") | |
google_nbrand_q = as.data.frame(data_gsc[-grep("бренд|brand", data_gsc$query),]) | |
g_nbrand_ctr = data.frame(sum(google_nbrand_q$impressions), sum(google_nbrand_q$clicks)) | |
names(g_nbrand_ctr) <- c("Shows", "Clicks") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
total_ctr = brand_ctr | |
total_ctr = InsertRow(total_ctr, non_brand_ctr) | |
total_ctr = InsertRow(total_ctr, g_brand_ctr) | |
total_ctr = InsertRow(total_ctr, g_nbrand_ctr) | |
rownames(total_ctr) <- c("Yandex brand", "Yandex non brand", "Google brand", "Google non brand") | |
percent <- function(x, digits = 2, format = "f", ...) { | |
paste0(formatC(100 * x, format = format, digits = digits, ...), "%") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start_this = "2018-08-10" | |
end_this = "2018-08-11" | |
start_prev = "2018-08-08" | |
end_prev = "2018-08-09" |