解读Google Analytics多渠道漏斗互动

时间:2016-12-09 10:19:22

标签: r google-analytics

Google Analytics提供MCF data。我想使用这些数据来解释转换之前介质与R之间的相互作用。

为了简化,假设我有2行中间路径和与每条路径相关的转换总数:

  • 直接> cpc>有机> cpc>推荐>直接| 3次转换

  • 有机>直接> cpc>推荐> cpc>直接| 1次转换

使用R,您将如何管理数据框以获取此信息:

  • 每个频道在另一频道之前的次数。所以例如direct是在cpc之前(我的中等路径中“direct> cpc”的出现次数加权转换次数)

问题在于,当我继续时,最终数据帧的列数很大(每个通道组合1个)。

  1. 您如何操纵R中的数据以获得“清晰”且可解释的数据框?
  2. 您会使用相同的方法还是使用简单的方法?
  3. 你会使用哪些R包(从现在起我只是使用stringr来操作路径字符串)?
  4. 另外,您是否知道可以执行更多图形分析的映射包?
  5. 感谢。

    西尔

1 个答案:

答案 0 :(得分:1)

以下是一个例子:

df <- read.table(sep="|", stringsAsFactors = F, text="
direct > cpc > organic | 3 conversions
organic > direct > cpc > email | 1 conversion
cpc > email | 10 conversion")
df[,1] <- trimws(df[,1])
df[,2] <- as.integer(gsub("\\D","",df[,2]))
lst <- strsplit(df[,1], " > ", T)
lst <- lapply(lst, function(x) matrix(embed(x, 2)[, 2:1], ncol=2))
res <- as.data.frame(do.call(rbind, lst))
res$V3 <- rep(df[,2], sapply(lst, nrow))
(res <- aggregate(V3~V1+V2, res, sum))
#        V1      V2 V3
# 1  direct     cpc  4
# 2 organic  direct  1
# 3     cpc   email 11
# 4     cpc organic  3

library(igraph)
g <- graph_from_data_frame(setNames(res, c("source", "target", "weight")))
plot(
  g, 
  edge.width = plotrix::rescale(E(g)$weight, c(1,5)), 
  edge.label = E(g)$weight
)

enter image description here

您可能还想查看包channelAttribution以了解归因建模。

相关问题