Markov Chain in Multi-Channel Attribution Modeling (Python code with real world case study)

Chloe Wei
5 min readJan 5, 2021

What’s the best channel for your marketing efforts? An analytical, data-driven approach to developing marketing strategy and optimizing budget allocation.

As a marketer for any businesses, we’re constantly asking these questions: “What channel is the most powerful?” “How can I know the impact of each channel on overall conversion?” (when there is a marketing setup which involves multiple channels (Ads, Website pages, Social Media post) that aims to drive the client to a conversion).

Marketers try to figure out the optimal allocation of marketing resources across available channels (usually to generates most conversions). In order to do this, it is necessary for marketers to determine the value of each channel and invest wisely. However, one of the most common mistakes marketers make is to credit the wrong marketing channel contributing to the conversion and e-commerce transactions.

The point in time when a potential customer interacts with a campaign is called a touchpoint, and a collection of touchpoints forms a buyer journey. Customer journeys are ever-changing and have become a lot more complex as today’s shopper is exposed to many different touchpoints across various devices and platforms — social media ads, email marketing, Google ads, and even billboards (not every touchpoint is digital). This is why it’s crucial to assign proper credit to each touchpoint so that marketers can determine where the budget should be spent —cue multi-touch attribution.

What are Multi-Channel Attribution Models?

Multi-channel attribution modeling is a method of analyzing various touchpoints and their impact in a sale or conversion across the customer journey, and assigning an appropriate amount of credit to each touchpoint in the path to conversion.

Leveraging Multi-Channel Attribution Models

As mentioned above, these touch points are great opportunities for marketers to educate and build relationships with prospects, also encourage and prepare them for the final stage of the buyers journey. The better the experience and the more value each of these touch points provide to the prospects, the more likely these leads would convert.

And as a marketer, if one can utilize the data and identify what role each channel plays and what impact each of them has on customers before eventually making a purchase or converting, this information would significantly enable the marketers especially on strategy development, budget allocation, and channel optimization.

Types of (traditional) Multi-Channel Attribution Models

Attribution models provided by Google analytics

Depending on your goals and what you’re trying to measure, you can approach your analysis by using different attribution models.

For example, you can look at First Interaction for awareness generation and Last Interaction for final conversion. But as a a general approach, you can start by using the linear attribution model. This will give equal credit to each channel that played a role in the conversion process. Next, use last non-direct click modeling to filter out direct clicks from your conversions. Be sure to use position-based attribution to give more credit to the first and last touch points while still giving credit to the middle points. Try using the time decay model to give credit to the channels that were closest in time to the conversion.

Limitations of traditional models

All attribution models have their pros and cons, but one drawback the traditional models have in common is that they are rules based. The user has to decide up front how they want the credit for sales events to be divided between the touchpoints. This means your results are based on your own presumptions, and therefore can be biased.

Markov Chain

What is Markov chain?

A Markov chain is a probabilistic automaton describing a sequence of possible events in which the probability of each event depends only on the state attained in the previous event. It essentially consists of a set of transitions, which are determined by some probability distribution that satisfy the Markov property.

The diagram below would be a representation of a Markov chains for multi-channel attribution:

by Jeremy Nelson

The arrows originate from the current state and points to the future state. And each arrow is called a transition from one state to the other. The future state depends only on the current state, not the steps before.

This illustrates the Markov property — memory less, a unique characteristic of Markov processes.

If you want to know more about Markov chains and its use cases you can visit this article.

Markov chains for multi-channel attribution

Why should I use it to solve the multi-channel attribution problem?

Imagine a process of a customer journey, starting with the first interaction with a new customer, leading to a conversion (or not) in which these touchpoints are different marketing channels with which a potential customer might interact (organic search, paid search, social etc.) with. We can determine the connections among these channels/touchpoints, and form a relationship network (connected by probabilities) using Markov chians.

How does that work?

Well, with a Markov chain model, we can leverage the principle of removal effect. This mean we examine what would happen to the overall conversions if we took one of those channels out.

By removing each channel and seeing how many conversions occur without that channel being in place, we can determine the contribution of a channel in a customer’s journey. In other words, it answers these question:

  • how much does a given channel affect the probability of conversion?
  • which touch points are the most important in the customer journey?

While the attribution models in Google Analytics are very useful, this method goes beyond the simple attribution to first click, last click, linear and so on.

Sounds amazing doesn’t it? Now, you may want to ask, well how can I do this?

Well, you’re at the right place!

If you want to check out the how to leverage Markov chain using Python, you can check out Jeremy Nelson’s github.

And if you want to see how I’ve applied Markov chain on this dataset, you can see it here at my github.

photo by Nathan Dumlao

--

--

Chloe Wei

Probably a pm, digital marketer, data analyst, and a social activist. Definitely a curious cat.