Enhancing Marketing Attribution Through Predictive Visualization With Markov Chain
Bj?rn Thomsen
Marketing Lead at meshcloud.io | Driving B2B Market Growth for Platform Engineering Company | Performance Marketing, Data Analytics, Marketing Strategy
For those engaged in high-level multi-channel marketing, the goal is to extract the absolute maximum from their budgets. Even single-digit improvements in conversion rates can provide a competitive advantage in fiercely contested markets.
In addition to the well-known heuristic multi-touch attribution models and data-driven models, which sometimes feel like magic boxes due to their machine learning approaches, more and more companies are taking attribution into their own hands, placing their trust in the Markov Chain.
In the following, I'll provide an overview of resources and examples to guide you in creating your own initial Markov Chain with Python. This will help you visualize the effectiveness of interaction points such as Google Ads, Email, or Linkedin.
What is The Markov Chain?
In simple terms, a Markov chain is a mathematical model that describes a system's transitions between different states. The crucial Markov property states that the probability of moving to a future state depends only on the current state, not on the sequence of past events. This concept involves states, transitions, and transition probabilities: https://www.avayant.com/post/building-an-attribution-model-with-markov-chains
Decoding The Dance of Customer Interactions
For Conversion Optimization, Markov chains are essential in understanding and predicting customer journeys through various marketing channels. The model analyzes the likelihood of a customer moving from one interaction state to another based solely on their current interaction, not considering the history of previous interactions. This approach helps decode the intricate dance between marketing channels, providing insights into the sequence of customer encounters and their impact on conversions.
Markov chains operate on probabilities, creating a compelling story of customer interactions and revealing the enchanting choreography of how different channels work together to lead customers to conversion.
Other Attribution Model
Why do we Prefer Markov Chain?
Markov chains have their focus on the dynamic order of customer interactions. Unlike many other models that rely on static rules, Markov chains operate on the probability of one interaction influencing the next, solely based on the current interaction. This allows for a nuanced understanding of how various marketing channels work together in sequence, providing insights into the evolving probabilities of customer journeys and their impact on conversions.
The model's reliance on probabilities makes it a powerful tool for decoding the intricate dance between interactions and optimizing the path to conversion.
Resources For Implementing Markov Chain
To employ the Markov Chain for marketing attribution (without relying on tracking codes or APIs to be handed over to any third-party service), a consistent dataset with user interaction points is required, spanning from the initial interaction to conversion or interaction termination. Assuming the setup is correct, platforms such as Google Analytics or Matomo can provide such data. Some companies take it a step further by integrating a Data Warehouse, ensuring independence from Data-Driven Attribution models, which increasingly incorporate Machine Learning, often appearing as a black box to marketers.
1. Python Implementation of Markov Chain
For those eager to delve into Python for implementation, I highly recommend the following outstanding article. It utilizes well-known libraries such as pandas, numpy, seaborn, and collections to illustrate the entire process of a simple marketing attribution Markov Chain. Copying the article can be found here: https://medium.com/@akanksha.etc302/python-implementation-of-markov-chain-attribution-model-0924687e4037
2. PoC: First-Order Markov Chain
A simpler approach involves using the "markov_model_attribution" library, serving more as a proof-of-concept. It leverages a fractional attribution model, employing a first-order Markov chain to reallocate conversions. You can find it here: https://github.com/jerednel/markov-chain-attribution
Please note: The library is unfortunately poorly maintained and requires a downgrade of the utilized resources.
3. Comparing Heuristic With Probabilistic Models in Python
Alternatively, I recommend this approach, also accompanied by relevant source code. The ChannelAttribution library is used to compare and visualize various Heuristic Multi-Touch and Probabilistic Attribution models. You can find it here: https://pypi.org/project/ChannelAttribution/
Note: I have thoroughly tested it and discovered a minor caveat – it requires the Microsoft Visual C++ 14.0 Framework or higher.
Visualizing The Markov Chain
In the final step, we aim to visualize the developed Markov Chain. To do this, we'll start by installing the markovchain Library from the console: (https://github.com/NaysanSaran/markov-chain
pip install markovchain
Next, we populate a multi-dimensional array, which already reflects the conversion rates of different interaction points, with hypothetical values from Channels like Google, YouTube (YT), or LinkedIn. Before we start, we have to import the markovchain Library - and other required libraries like numpy and matplotlib.
import matplotlib.patches as mpatches
from matplotlib.collections import PatchCollection
import matplotlib.pyplot as plt
import numpy as np
from markovchain import MarkovChain as mc
P = np.array([
[0.7, 0.1, 0.0, 0.1, 0.1, 0.0, 0.0],
[0.5, 0.3, 0.0, 0.1, 0.1, 0.0, 0.0],
[0.5, 0.1, 0.0, 0.0, 0.1, 0.3, 0.0],
[0.3, 0.2, 0.0, 0.1, 0.3, 0.0, 0.1],
[0.2, 0.0, 0.0, 0.4, 0.2, 0.2, 0.0],
[0.5, 0.1, 0.0, 0.1, 0.2, 0.1, 0.0],
[0.4, 0.1, 0.0, 0.2, 0.2, 0.1, 0.0],
])
attribution = mc(P, ['Conversion', 'Google', 'Line', 'YT', 'SEO', 'LinkedIn', 'TikTok'])
Then, using the draw-method, we generate a simple, easily readable 7-State Markov Chain.
attribution.draw("markov_chain.png")
Conclusion
Utilizing the Markov Chain for marketing attribution can particularly add value when dealing with substantial advertising budgets and numerous interaction points, surpassing outdated heuristic models and aiding in enhancing conversion rates. The resources showcased in this article provide an initial avenue for exploration.