This case study explores how different marketing touchpoints contribute to customer conversions.
KNC wants to understand how to assign credit fairly across multi‑touch customer journeys.
Task 1 — Three questions from Section 1
Which touchpoints are most influential in driving conversions?
How should conversion credit be allocated across multi‑touch paths?
How do different attribution models change the perceived value of each channel?
Task 1 — Attribution methods
Heuristic-based models - First-touch: 100% credit to the first interaction.
- Last-touch: 100% credit to the final interaction before conversion.
- Linear: Equal credit to all touchpoints.
- Position-based / time-decay: Weighted credit based on position or recency.
Probability-based models - Markov chain model: Uses transition probabilities and removal effects to estimate channel contribution.
- Shapley value: Game‑theoretic method that averages each channel’s marginal contribution across all possible channel combinations.
This section explores the data set & visualizes attribution results.
Code
H <-heuristic_models( PathData,var_path ="path",var_conv ="conv",var_value ="value")
[1] "*** Install ChannelAttribution Pro for free! Run install_pro(). Set flg_pro=FALSE to hide this message."
Code
M <-markov_fixed( PathData,var_path ="path",var_conv ="conv",var_value ="value")S <-shapley_fixed( PathData,var_path ="path",var_conv ="conv",var_value ="value")R <-merge(H, S, by ="channel_name", all =TRUE)
7 Melt + Bar Plot
Code
R_melt <-melt(R, id ="channel_name")ggplot(R_melt, aes(x = channel_name, y = value, fill = variable)) +geom_bar(stat ="identity", position ="dodge") +coord_flip()
8 Transition Matrix
Code
M$transition_matrix
# A tibble: 14 × 3
# Groups: from [5]
from to prob
<chr> <chr> <dbl>
1 display email 0.5
2 display social 0.5
3 email direct 0.8
4 email paid_search 0.2
5 paid_search direct 0.5
6 paid_search email 0.25
7 paid_search social 0.25
8 social direct 0.75
9 social email 0.25
10 start direct 0.1
11 start display 0.2
12 start email 0.2
13 start paid_search 0.3
14 start social 0.2
9 Removal Effect
Code
M$removal_effect
display email paid_search social start direct
0 0 0 0 0 0
Task 3 — Fixing errors
Common issues include: - Incorrect column names in ggplot
- Missing factor ordering
- Using the wrong variable names from the model output
Check names(R) and names(M) to ensure the visualization uses the correct columns.
Task 3 — Probability of start > paid_search > conversion
Use the transition matrix:
[ P = P(start paid_search) P(paid_search conversion) ]
Insert your actual values from M$transition_matrix here.
Code
H <-heuristic_models( PathData,var_path ="path",var_conv ="conv",var_value ="value")
[1] "*** Install ChannelAttribution Pro for free! Run install_pro(). Set flg_pro=FALSE to hide this message."
Code
M <-markov_fixed( PathData,var_path ="path",var_conv ="conv",var_value ="value")S <-shapley_fixed( PathData,var_path ="path",var_conv ="conv",var_value ="value")R <-merge(H, S, by ="channel_name", all =TRUE)
10 4. Attribution models in R
This section runs heuristic, Markov, & Shapely attribution models
10.1 4.1 Heuristic models (first / last touch)
Code
H <-heuristic_models( PathData,var_path ="path",var_conv ="conv",var_value ="value")
[1] "*** Install ChannelAttribution Pro for free! Run install_pro(). Set flg_pro=FALSE to hide this message."
Heuristic models assign credit using simple rules.
They are easy to interpret but ignore sequence effects.
10.2 4.2 Markov chain model
Code
M <-markov_model( PathData,var_path ="path",var_conv ="conv",var_value ="value",order =1)
Number of simulations: 100000 - Convergence reached: 0.68% < 5.00%
Percentage of simulated paths that successfully end before maximum number of steps (6) is reached: 98.83%
[1] "*** Install ChannelAttribution Pro for free running install_pro(). Visit https://channelattribution.io for more info. Set flg_pro=FALSE to hide this message."
The Markov model uses transition probabilities and removal effects to estimate each channel’s contribution.
10.3 4.3 Shapley-value-based approach
Code
S <-shapley_manual( PathData,var_path ="path",var_conv ="conv",var_value ="value")S
channel_name shapley_value
start start NaN
email email 112.000000
direct direct NaN
paid_search paid_search -3.333333
social social -70.000000
display display -2.500000
Note
The Shapley method evaluates each channel’s marginal contribution across all possible channel combinations.
11 5. Results and interpretation
This section compares the outputs of all attribution models
channel_name shapley_value total_conversion total_conversion_value
1 direct NaN 1.7846274 214.22381
2 display -2.500000 0.2975281 35.64629
3 email 112.000000 1.3313887 159.52158
4 paid_search -3.333333 0.5124196 61.61773
5 social -70.000000 0.2894088 34.76676
6 start NaN 1.7846274 214.22381
Task 4 — Interpretation of attribution results
First-touch: Rewards channels that initiate journeys.
Last-touch: Rewards channels that close conversions.
Markov: Rewards channels that are essential in the transition structure.
Shapley: Rewards channels with high marginal contribution across combinations.
Summarize which channels gained or lost credit in your output.
Task 5 — Shapley drop in conversion probability
Channels with the largest Shapley values cause the biggest drop in conversion probability when removed.
Interpret which channels are most critical based on your results.
14 6. Discussion of modeling approaches
Task 6 — Strengths and weaknesses
Markov model - Strengths: sequence-aware, uses removal effects, good for path analysis
- Weaknesses: sensitive to sparse data, assumes Markov property
Shapley value - Strengths: fair allocation, considers all channel combinations
- Weaknesses: computationally heavy, less intuitive for non-technical audiences
Task 7 — How Shapley supplements Markov
Shapley values validate and complement Markov results by: - Confirming which channels consistently contribute across combinations
- Highlighting channels that assist indirectly
- Providing a fairness-based perspective to balance Markov’s sequence-based view