Skip to main content
Version: Latest

uam

R

library(ChannelAttributionPro)

token <- "yourtoken"

df_aggr <- read.csv("https://app.channelattribution.io/data/data_mmm.csv")

D_variables <- data.frame(
variable = c(
"direct_searches",
"facebook_impressions",
"facebook_cost",
"google_impressions",
"google_clicks",
"google_cost"
),
channel = c(
"direct",
"facebook_ads",
"facebook_ads",
"google_ads",
"google_ads",
"google_ads"
),
measure = c(
"direct_searches",
"impressions",
"cost",
"impressions",
"clicks",
"cost"
),
stringsAsFactors = FALSE
)

target <- "revenue"

Aggregated-data attribution without customer journey paths:

res <- uam(
df_aggr = df_aggr,
D_variables = D_variables,
target = target,
df_paths = NULL,
baseline_model = "reward_model", # default; use "auto_mmm" to use the MMM baseline
max_p = 12,
nsim = 1000,
seed = 1234567,
verbose = 1,
password = token
)

print(head(res))

With already aggregated customer journey paths:

df_paths <- read.csv("https://app.channelattribution.io/data/data_uam_paths_t.csv", sep = ";")

res <- uam(
df_aggr = df_aggr,
D_variables = D_variables,
target = target,
df_paths = df_paths,
baseline_model = "reward_model", # or "auto_mmm"
var_path = "path",
var_conv = "total_conversions",
var_null = "total_null",
order = 1,
sep = ">",
verbose = 1,
password = token
)

print(head(res))

With event-level customer journey paths:

df_paths <- read.csv("https://app.channelattribution.io/data/data_uam_paths.csv", sep = ";")

res <- uam(
df_aggr = df_aggr,
D_variables = D_variables,
target = target,
df_paths = df_paths,
baseline_model = "reward_model", # or "auto_mmm"
channel_conv = "((CONV))",
order = 1,
sep = ">",
verbose = 1,
password = token
)

print(head(res))