I'm trying to make API calls to Google Analytics and need to send regular expression as part of call using googleAnalyticsR package.
regular expression can be sent because I have special charaacter() in it. using double \ make it wrong when sent to API.
library(googleAnalyticsR)
date_range = c("2019-03-01", "2019-03-10")
view_id = "12345678"
reg_exp <- "(www.abc.com)\.*"
se <- segment_element("pagePath",
operator = "REGEXP",
type = "DIMENSION",
expressions = reg_exp,
scope = "SESSION")
sv_simple <- segment_vector_simple(list(list(se)))
seg_defined_one <- segment_define(sv_simple)
segment4 <- segment_ga4("simple", user_segment = seg_defined_one)
data <- google_analytics(view_id,
date_range = date_range,
metrics = c("pageviews", ""),
dimensions = c("pagePath"),
segments = segment4)
How can I set the correct regexp in that variable?
fortunes::fortune(365)
, escape the special character "\" with "\":"(www.abc.com)\\.*"