ChannelAttribution
Markov Model for Online Multi-Channel Attribution
Install / Use
/learn @DavideAltomare/ChannelAttributionREADME
What is multi-touch attribution?
Multi-touch attribution is a method of marketing measurement that considers all touchpoints on the customer journey and allocates a certain amount of credit to each channel. This allows marketers to understand the value that each touchpoint contributes to driving a conversion. For instance, suppose a consumer is contemplating the purchase of a new smartphone. After conducting some research, they come across ads. Initially, they encounter a display ad, which they overlook. Subsequently, they notice a native ad on their Instagram feed, capturing their attention and redirecting them to a website. Finally, they receive a promotional offer via email, complete with a discount code that motivates them to make the purchase.
Each of these ads represents a touchpoint in the buyer's journey. With multi-touch attribution, marketers can examine the impact of the native ad and the email campaign, attributing the sale to these specific efforts. Meanwhile, they can recognize that the display ad was ineffective and make adjustments accordingly.
There are various multi-touch attribution models available to marketers, analyzing user-level data such as clicks and impressions to understand the influence of these events on the ultimate goal. These models vary in their evaluation of ad effectiveness, offering marketers diverse perspectives to shape their strategies.
Multi-touch attribution models
Multi-touch attribution models aim to assign credit to different touchpoints in the customer journey. There are two families of attribution models: heuristic models and probabilistic models.
<h2>1. Multi-Touch Attribution Heuristic Models:</h2>Heuristic models follow predefined rules to allocate credit to various touchpoints. These rules are often based on assumptions or industry best practices. Simplicity: Heuristic models are generally simpler and easier to implement. They use straightforward rules to distribute credit, making them more accessible for marketers who may not have extensive statistical expertise. Transparency: These models provide clear and understandable rules for assigning credit, offering transparency in the decision-making process. Examples of Heuristic Models are:
-
<b>First touch Attribution</b>: Attributes all credit to the first touchpoint in the customer journey, emphasizing the initial interaction's role in driving the conversion.
-
<b>Last touch Attribution</b>: Attributes all credit to the last touchpoint in the customer journey, highlighting the final interaction as the most influential in the conversion process.
-
<b>Linear Attribution</b>: Distributes credit equally to all touchpoints
Probabilistic models use statistical techniques and algorithms to analyze data and determine the probability of each touchpoint contributing to the conversion. Complexity: These models are often more complex than heuristic models, as they involve analyzing large datasets and considering various factors to determine credit allocation. Customization: Probabilistic models can be customized based on specific business requirements and nuances, allowing for a more tailored and accurate representation of the customer journey. Examples of Probabilistic Models:
-
<b>Markov Chain Models</b>: Analyzes the sequence of touchpoints to determine the transition probabilities between them.
-
<b>Algorithmic Models</b>: Utilizes machine learning algorithms to predict the likelihood of each touchpoint influencing a conversion.
<i>Key Considerations:</i>
- <b>Flexibility</b>: Probabilistic models are often more flexible and adaptive to different business scenarios, while heuristic models may be less flexible but easier to implement.
- <b>Accuracy</b>: Probabilistic models are generally considered more accurate because they are data-driven and can adapt to changes in consumer behavior over time.
- <b>Resource Requirements</b>: Implementing and maintaining probabilistic models may require more resources, both in terms of data infrastructure and expertise, compared to heuristic models.
In summary, while heuristic models rely on predefined rules for credit allocation, probabilistic models leverage data-driven approaches and statistical techniques to provide a more nuanced and adaptable understanding of the customer journey. The choice between the two depends on factors such as the complexity of the business, the availability of data, and the desired level of accuracy and customization.
ChannelAttribution
ChannelAttribution is a Python and R library that employs a k-order Markov representation to identify structural correlations in customer journey data. Additionally, the library incorporates three heuristic algorithms (first-touch, last-touch, and linear-touch approaches) to tackle the same problem. These algorithms are implemented in C++ and are well-suited for handling large-scale problems involving hundreds or thousands of channels.
<h2>Installation</h2> <h3>Python</h3>/python contains Python library source code
<b>NOTE</b>: Only Python3 is supported! Note! Only Python3 is supported! Installation on Windows requires Microsoft Visual C++ 14.0 or greater.
<b>From PyPi</b>
pip install --upgrade setuptools
pip install Cython
pip install ChannelAttribution
<h3>R</h3>
/R contains R package source code
<b>From CRAN</b>
install.packages("ChannelAttribution")
<h2>Usage</h2>
<b>Python</b>
In the following example we will show how Python library ChannelAttribution can be used to perform multi-touch attribution using heuristic models and Markov model.
First of all we need to load ChannelAttribution and data containing customer journeys:
import numpy as np
import pandas as pd
from ChannelAttribution import *
import plotly.io as pio
Data = pd.read_csv("https://channelattribution.io/csv/Data.csv",sep=";")
Now we can performe attribution with heuristic models:
H=heuristic_models(Data,"path","total_conversions",var_value="total_conversion_value")
We can also performe attribution with Markov model:
M=markov_model(Data, "path", "total_conversions", var_value="total_conversion_value")
Now we can merge attributed conversion for each method:
R=pd.merge(H,M,on="channel_name",how="inner")
R1=R[["channel_name","first_touch_conversions","last_touch_conversions",\
"linear_touch_conversions","total_conversions"]]
R1.columns=["channel_name","first_touch","last_touch","linear_touch","markov_model"]
R1=pd.melt(R1, id_vars="channel_name")
data = [dict(
type = "histogram",
histfunc="sum",
x = R1.channel_name,
y = R1.value,
transforms = [dict(
type = "groupby",
groups = R1.variable,
)],
)]
and plot them
fig = dict({"data":data})
pio.show(fig,validate=False)
<img src="https://app.channelattribution.net/img/python_total_conversion.png" width="100%" height="auto" >
<br />
We can also get the same plot in terms of attributed conversion value:
R2=R[["channel_name","first_touch_value","last_touch_value",\
"linear_touch_value","total_conversion_value"]]
R2.columns=["channel_name","first_touch","last_touch","linear_touch","markov_model"]
R2=pd.melt(R2, id_vars="channel_name")
data = [dict(
type = "histogram",
histfunc="sum",
x = R2.channel_name,
y = R2.value,
transforms = [dict(
type = "groupby",
groups = R2.variable,
)],
)]
<img src="https://app.channelattribution.net/img/python_total_value.png" width="100%" height="auto" >
<br />
<br />
<b>R</b>
In the following example we will show how R package ChannelAttribution can be used to perform multi-touch attribution using heuristic models and Markov model.
First of all we need to load ChannelAttribution and data containing customer journeys:
library(ChannelAttribution)
library(reshape2)
library(ggplot2)
data(PathData)
Now we can performe attribution with heuristic models:
H=heuristic_models(Data,"path","total_conversions",var_value="total_conversion_value")
We can also performe attribution with Markov model:
M=markov_model(Data, "path", "total_conversions", var_value="total_conversion_value")
Now we can merge attributed conversion for each method:
R=merge(H,M,by="channel_name")
R1=R[,(colnames(R)%in%c("channel_name","first_touch_conversions","last_touch_conversions",
"linear_touch_conversions","total_conversion"))]
colnames(R1)=c("channel_name","first_touch","last_touch","linear_touch","markov_model")
R1=melt(R1,id="channel_name")
and plot them
ggplot(R1, aes(channel_name, value, fill = variable)) +
ggtitle("")+
geom_bar(stat="identity", position = "dodge") +
theme(plot.title = element_text(hjust = 0.5))+
theme(text = element_text(size=14)) +
theme(plot.title=element_text(size=18)) +
theme(legend.title = element_blank()) +
ylab("") +
xlab("")
<img src="https://app.channelattribution.net/img/R_total_conversion.png" width="100%" height="auto" >
<br />
We can also get the same plot in terms of attributed conversion value:
R2=R[,(colnames(R)%in%c("channel_name","first_touch_value","last_touch_value","linear_touch_value",
"total_conversion_value"))]
colnames(R2)=c("channel_name","first_touch","last_touch","linear_touch","markov_model")
R2=melt(R2,id="channel_name")
ggplot(R2, aes(channel_name, value, fill = variable)) +
ggtitle("")+
geom_bar(stat="identity", position = "dodge") +
theme(plot.title = element_text(hjust = 0.5))+
theme(text = element_text(size=14)) +
theme(plot.title=element_text(size=18)) +
theme(lege
Related Skills
bluebubbles
349.9kUse when you need to send or manage iMessages via BlueBubbles (recommended iMessage integration). Calls go through the generic message tool with channel="bluebubbles".
bear-notes
349.9kCreate, search, and manage Bear notes via grizzly CLI.
claude-seo
4.1kUniversal SEO skill for Claude Code. 19 sub-skills, 12 subagents, 3 extensions (DataForSEO, Firecrawl, Banana). Technical SEO, E-E-A-T, schema, GEO/AEO, backlinks, local SEO, maps intelligence, Google APIs, and PDF/Excel reporting.
claude-ads
1.6kComprehensive paid advertising audit & optimization skill for Claude Code. 186 checks across Google, Meta, YouTube, LinkedIn, TikTok & Microsoft Ads with weighted scoring, parallel agents, and industry templates.
