crm_keywords <- read_ads_csv_skip2(keyword_files["CRM"])
trm_keywords <- read_ads_csv_skip2(keyword_files["TRM"])
keyword_df <- bind_rows(
crm_keywords |> mutate(program = "CRM"),
trm_keywords |> mutate(program = "TRM")
)
match_col <- intersect(
c("match_type",
"keyword_match_type",
"search_term_match_type",
"match_type_with_variant"),
names(keyword_df)
)[1]
if (is.na(match_col)) {
keyword_df <- keyword_df |>
mutate(match_type_clean = "Match Type Not Available")
} else {
keyword_df <- keyword_df |>
mutate(
match_type_clean =
str_to_title(as.character(.data[[match_col]]))
)
}
keyword_summary <- keyword_df |>
mutate(clicks = to_num(clicks)) |>
group_by(program, match_type_clean) |>
summarise(
clicks = sum(clicks, na.rm = TRUE),
.groups = "drop"
) |>
group_by(program) |>
mutate(
click_share = clicks / sum(clicks, na.rm = TRUE)
) |>
ungroup()
ggplot(keyword_summary,
aes(x = click_share,
y = fct_reorder(match_type_clean,
click_share),
fill = program)) +
geom_col(show.legend = FALSE) +
facet_wrap(~program) +
scale_x_continuous(labels = percent) +
labs(
title = "Match Type Click Share by Program",
subtitle = "Broad match dominates CRM and TRM traffic",
x = "Share of Clicks",
y = NULL
) +
theme_minimal(base_size = 12) +
theme(
plot.title = element_text(face = "bold")
)