Skip to main content

new_paths_attribution R Code

R

#Load library and data

library(ChannelAttributionPro)

data(PathData)

password="yourpassword"

download.file(url="https://channelattribution.net/csv/Data.csv","Data.csv")

#make attribution on new paths after you have trained a Markov model

train=markov_model(Data=Data, var_path="path", var_conv="total_conversions",
var_value="total_conversion_value", cha_sep=">", password=password)
path_attribution=res$attribution

res=new_paths_attribution(Data=Data[1:5], var_path="path", var_conv="total_conversions",
Dparams=train$parameters, var_value="total_conversion_value",
row_sep=";", cha_sep=">", flg_write_nulls=0, flg_write_paths=1,
server="app.channelattribution.io", password=password)
print(res$attribution)

#Perform transaction level attribution reading data from a file and write output to file

res=new_paths_attribution(Data="Data.csv", var_path="path", var_conv="total_conversions",
Dparams=train$parameters, var_value="total_conversion_value",
row_sep=";", cha_sep=">", flg_write_nulls=0, flg_write_paths=1,
file_output="ouput.csv", server="app.channelattribution.io",
password=password)
print(res$attribution)