Data Science
Markov Chain Attribution: Customer Journeys, Conversion and Null Paths
Part 5: Building a Markov chain, Why null paths matter?, and How the removal effect measures each channel?
- Parts 1 to 4: Markov chains,TPM and the removal effect
- How a customer journey maps onto a Markov chain: Start, channel touchpoints, then Conversion or Null
- Why null paths are needed, and what they show that rule-based models miss
- How to work out each channel's removal effect and share of credit, step by step on six example journeys
- How the same steps scale to 50,000 journeys, with an interactive chart
Parts 1 - 4 explained thought traffic example of cars in the city of Sampur, a fictional city with four junctions, an airport and a lot of traffic that never reached it. This blog post follows on the same ideas however the labeles are changed:
- Junctions become marketing channels,
- Airport becomes a purchase
- Leaving the city becomes a customer journey that ends without a purchase.
This blog post uses Kesari Threads, the fictional D2C ethnic-wear brand from the Marketing Channel Attribution series. That series showed how rule-based models such as Last Non Direct Click and Linear hand out credit. This part shows how a Markov chain does it differently, and Part 6 compares the two on the same data.
Road trip mapped to a Customer Journey
A car's trip and a customer's online website journey is same. Each starts somewhere, passes through a few intermediate steps, and ends in one of two outcomes.
Figure 1: A road trip and a customer journey built from the same Markov chain parts.
| Markov term | In Sampur | Kesari Threads |
|---|---|---|
| Starting state | City entry | Customer's first visit |
| Transient state | A junction (Market Square, Ring Road, Flyover) | A channel touchpoint (Instagram Ads, Google Shopping, Email…) |
| Transition probability | Chance of turning onto the next road | Chance that the next visit comes from a given channel |
| Absorbing state: Success | Airport | Conversion: Customer buys |
| Absorbing state: no success | Left city | Null: Journey ends without a purchase |
| Closing a junction | Traffic diverted out of the city | Switching a channel off |
| Removal effect | Share of airport arrivals lost | Share of conversions lost |
Table 1: Markov terms Mapped between Sampur and at Kesari Threads.
A touchpoint is one visit to the site, labelled by the channel name(source/medium) that brought the customer. In GA4 that label comes from the Source and Medium of the session, grouped into channels such as Paid Social or Organic Search. Kesari's analysts group them into six channels: Instagram Ads, Influencer, Google Shopping, Email, Brand Search and Direct.
💡 Tip: Build the channel grouping before building the model. 5 - 10 channels is a sensible starting point. Anything more not only complicates the model creation but evaluation and implementation too.
Conversion & Null paths
Every journey ends either in one of two ways:
- A conversion path ends with a purchase. These are the journeys that every rule based attribution report already counts.
- A Null path is a customer journey that ends without a purchase. The customer visited, perhaps more than once, and then stopped coming back within the analysis window.
The below figure show 6 customer journey at Kesari Threads. These customer journeys are used further for explanation further in this blog.
Figure 2: Three conversion paths and three null paths from Kesari Threads.
The rule-based models earlier in this series looks only at journeys 1 - 3 which are conversion paths. Journeys 4 - 6 never are non-conversion paths therefore they are never consider in the rule based attribution like Last Non-Direct Click or Linear Report, because there is no sale to share out.
Null paths are the "Left city" as per the car traffic example. In Sampur, the 49.5% of cars that reached the airport only made sense next to the 50.5% that left. In a real online website the null paths are the large majority. Of Kesari's 50,000 simulated journeys, 46,794 end in Null and only 3,206 convert, a conversion rate of 6.41%. Therefore there is a lot more to learn from the null paths since they forms alomost 94% of all customer journeys than the conversion paths which only make up about 6%. The next section shows how they are used in a Markov model.
Leaving the null paths out and every journey in the data ends in a sale. The model would then conclude that every channel leads to a purchase 100% of the time, and it could never tell a channel that loses most of its visitors from one that keeps them.
📌 Key idea: A Markov attribution model needs both kinds of journey. Conversion paths show where sales come from. Null paths show where customers drop out, and that is what turns raw counts into probabilities.
This matters because sales are rare. A typical e-commerce or retail website converts only around 4% of its visits. A rule-based model such as Last Non-Direct Click (LNDC) builds its whole analysis from that 4% and ignores the other 96% of journeys: the goldmine of data on where and why customers drop out. Kesari's simulated conversion rate of 6.4% tells the same story.
Building the Markov Chain
This method is the same one that was used in Part 2 for Sampur's trip log. Now we apply it to customer journeys.
Step 1: Count every move. Each journey is written from Start to its ending, and every step from one state to the next is counted.
Ex: Journey 6, has 4 moves namely: Start → Instagram Ads, Instagram Ads → Google Shopping, Google Shopping → Email and Email → Null. Similarly break each journey into moves and count them. The result is the transition count matrix. Table 2 shows the counts for the six journeys in Figure 2.
| From ↓ to → | Instagram Ads | Google Shopping | Conversion | Null | Row total | |
|---|---|---|---|---|---|---|
| Start | 4 | 2 | 0 | 0 | 0 | 6 |
| Instagram Ads | 0 | 2 | 1 | 0 | 1 | 4 |
| Google Shopping | 0 | 0 | 2 | 1 | 1 | 4 |
| 0 | 0 | 0 | 2 | 1 | 3 |
Table 2: Transition counts from the six journeys.
Step 2: Divide by the row total. Each count is then divided by its row total which gives the transition probability.
There are 6 journeys that start at Start. 4 of them go to Instagram Ads, so the probability is 4 ÷ 6 = 0.67. Two go to Google Shopping, so that probability is 2 ÷ 6 = 0.33. The other three channels have no moves from Start, so their probabilities are zero.
Once we do the above calcualation we get the Transition Probability Matrix (TPM). Table 3 shows the calculation for every cell, and in Figure 3 we draw a graph based on this result.
| From ↓ to → | Instagram Ads | Google Shopping | Conversion | Null | Row total | |
|---|---|---|---|---|---|---|
| Start | 4 ÷ 6 = 0.67 | 2 ÷ 6 = 0.33 | 0 | 0 | 0 | 1.00 |
| Instagram Ads | 0 | 2 ÷ 4 = 0.50 | 1 ÷ 4 = 0.25 | 0 | 1 ÷ 4 = 0.25 | 1.00 |
| Google Shopping | 0 | 0 | 2 ÷ 4 = 0.50 | 1 ÷ 4 = 0.25 | 1 ÷ 4 = 0.25 | 1.00 |
| 0 | 0 | 0 | 2 ÷ 3 = 0.67 | 1 ÷ 3 = 0.33 | 1.00 |
Table 3: The TPM: each count in Table 2 divided by its row total.
Every row adds up to 1. For Instagram Ads, 0.50 + 0.25 + 0.25 = 1.00. These are the numbers on the arrows in Figure 3.
Figure 3: The six journeys as one Markov chain, with transition probabilities on each arrow.
Solid arrows are moves to another channel or to Conversion. Dashed arrows go to Null. The probabilities leaving each box add up to 1, just as each junction's turning probabilities did in Sampur. Email is the most promising place to be: two of the three customers who reached it went on to buy.
Conversion Probability of each Journey
To find overall conversion probability, follow every route from Start to Conversion, multiply the probabilities along each route, and add the results. In Part 3 we did the same with routes to the airport.
| Route to Conversion | Calculation | Probability |
|---|---|---|
| Start → Instagram Ads → Google Shopping → Conversion | 0.67 × 0.50 × 0.25 | 8.3% |
| Start → Instagram Ads → Google Shopping → Email → Conversion | 0.67 × 0.50 × 0.50 × 0.67 | 11.1% |
| Start → Instagram Ads → Email → Conversion | 0.67 × 0.25 × 0.67 | 11.1% |
| Start → Google Shopping → Conversion | 0.33 × 0.25 | 8.3% |
| Start → Google Shopping → Email → Conversion | 0.33 × 0.50 × 0.67 | 11.1% |
| Total | 50.0% |
Table 4: Every route from Start to Conversion in the six-journey chain.
Three of the above five routes match a real journey from Figure 2 (Journeys 1, 2 and 3). The other two were taken by no customer:
- Start → Google Shopping → Conversion. Journey 5 started at Google Shopping but dropped out. The step from Google Shopping to Conversion comes from Journey 1.
- Start → Instagram Ads → Google Shopping → Email → Conversion. Journey 6 took the first three steps and then dropped out. The step from Email to Conversion comes from Journeys 2 and 3.
Figure 2: Three conversion paths and three null paths from Kesari Threads.
The chain still counts these routes because it only looks at where a customer is now, not how they got there. This is the Markov property from Part 1. A customer at Email has a 0.67 chance of converting whichever way they arrived. The model joins up pieces of different journeys into full routes, and with thousands of journeys behind each step, those pieces average out into a stable picture.
The total, 50.0%, matches the above data exactly i.e. 3 of the 6 journeys converted. With real data the routes loop back on themselves and working them manually stops being practical. The fundamental matrix from Part 4 helps with calcualtion and adds up every route, loops included, in one calculation. This fundamental matrix when built in a programming language like Python or R can be used to calculate the conversion probability of each journey in a large dataset.
The Removal Effect: Switching a Channel off
The removal effect asks the question from the closed flyover example in Part 1: What happens to conversions if this channel disappears?
The logic and rule is the same as closing a junction. Every customer who would have reached the removed channel goes to Null instead. In route terms, any route that passes through the channel is lost.
| Channel removed | Routes still open | Conversion probability | Removal effect |
|---|---|---|---|
| Instagram Ads | Start → Google Shopping → Conversion; Start → Google Shopping → Email → Conversion | 8.3% + 11.1% = 19.4% | 1 − 19.4 ÷ 50.0 = 61.1% |
| Google Shopping | Start → Instagram Ads → Email → Conversion | 11.1% | 77.8% |
| Start → Instagram Ads → Google Shopping → Conversion; Start → Google Shopping → Conversion | 16.7% | 66.7% |
Table 5: The removal effect of each channel in the six-journey example.
The formula is:
removal effect = 1 − (conversion probability without the channel
÷ conversion probability with every channel)Figure 4: The conversion probability with each channel removed in turn.
In Figure 4 the blue bar is the conversion probability with every channel on, and each red bar is the probability with one channel switched off. The gap between them, as a share of the blue bar, is the removal effect printed above each red bar.
📌 How to read these numbers: Each red bar is the chance that a journey still converts if that channel didn't exist.
- 19.4% (Instagram Ads removed): with every channel on, half of the journeys (50.0%) convert. Without Instagram Ads, only about 1 in 5 would. The two routes that avoid Instagram Ads stay open: 8.3% + 11.1% = 19.4%. Out of 6 journeys, that is about 1.2 sales instead of 3.
- 11.1% (Google Shopping removed): only about 1 in 9 journeys would convert, about 0.7 sales out of 6. Just one route avoids Google Shopping (Start → Instagram Ads → Email → Conversion, 0.67 × 0.25 × 0.67), which is why the same 11.1% appears in Table 4.
- 16.7% (Email removed) works the same way: about 1 in 6 journeys.
To interpret them: a lower bar means the channel matters more. The removal effect turns the drop into a share of sales: (50.0 − 19.4) ÷ 50.0 = 61.1% of conversions depend on Instagram Ads, and (50.0 − 11.1) ÷ 50.0 = 77.8% depend on Google Shopping. These are what-if estimates from the model. They assume a customer who would have reached the channel leaves instead. Real customers sometimes find another way in, which is why Part 6 recommends a holdout test before a big budget cut.
Each channel appears in exactly two of the three conversion paths, yet Google Shopping has the largest removal effect. It sits on four of the five routes in Table 4, so switching it off leaves only one route open. It plays the part of Sampur's Flyover here: no busier than the others, but on more of the routes that end in a sale.
From removal effects to credit
The three removal effects add up to 205.6%, because a single conversion depends on more than one channel. As in Part 3, each effect is divided by the total so the shares add up to 100%:
| Channel | Removal effect | Share of credit | Credit for the 3 conversions |
|---|---|---|---|
| Instagram Ads | 61.1% | 29.7% | 0.89 |
| Google Shopping | 77.8% | 37.8% | 1.14 |
| 66.7% | 32.4% | 0.97 | |
| Total | 205.6% | 100% | 3.00 |
Table 6: Removal effects scaled into credit for the six-journey example. Shares are rounded.
Compare that with last click on the same three sales: Email gets two, Google Shopping one, and Instagram Ads none, even though Instagram started two of the three. Part 6 makes this comparison on the full dataset.
Large Dataset: 50,000 Customer Journeys
6 journeys are enough to follow the arithmetic and logic. In a real model and data these are in thousands.
The simulated Kesari dataset for this series has 50,000 journeys over the six channels, with 2.0 touchpoints per journey on average and 2.5 per converting journey. The steps do not change:
- count the moves,
- build the TPM, and
- compute the probabilities with the fundamental matrix.
Figure 5: The chance of converting from each Kesari touchpoint, worked out from conversion and null paths.
Each bar in Figure 5 answers one question: once a customer has arrived through this channel, how likely are they to buy before the journey ends? The dashed line is the average for a journey that has just started, 6.4%. Green bars are above it and red bars below.
A customer arriving from Brand Search converts 12.2% of the time, close to twice the average. A customer arriving from an Influencer post converts 3.0% of the time, because most of them leave after one visit: 64% of moves out of Influencer go straight to Null. Neither number could be calculated from conversion paths alone.
The removal effect at this scale works exactly as it did with six journeys.
Try the simulation below.
Click a channel to switch it off. Everyone who would have reached it goes to Null, and the bars show how many conversions are lost. Switch off more than one channel to see how they overlap.
Conversions per 50,000 journeys: 3,206 → 3,206
Figure 6: Interactive removal effects for Kesari Threads, based on 50,000 simulated journeys.
Switching off Google Shopping drops the conversion probability from 6.41% to 3.33%, cutting conversions per 50,000 journeys from 3,206 to about 1,667. That is a removal effect of 48.0%, the largest of the six. Brand Search follows at 44.1%, then Instagram Ads at 39.5%, Direct at 38.9% and Email at 35.2%. Influencer is far behind at 12.9%. The six effects add up to 218.7%, and scaling them to 100% gives the Markov credit that Part 6 compares with the rule-based models.
Markov Model Assumption
The assumptions from Part 1 apply to journeys too:
- Only the current channel matters. A first-order chain ignores how the customer reached the current touchpoint. Part 3 showed how to test whether it is a second-order chain is needed.
- The probabilities are stable over the period analysed. A festive sale or a new campaign can change them, so models are usually rebuilt each month or quarter.
- Journeys are fully observed. Cookie loss, cross-device browsing and offline touches break journeys apart, and a broken journey can look like a null path.
- The result describes recorded flows. A removal effect shows what the observed patterns imply. Real customers might reach the site another way if a channel were switched off.
⚠️ Pitfall: Many analytics exports include only converting paths. If you build a Markov model from those alone, every transition into Null is missing, so the model can no longer show which channels lose customers. Export all journeys, including the ones that end without a purchase.
Common mistakes
- Dropping null journeys. The model can no longer see where customers drop out, and the conversion probability from each touchpoint loses its meaning.
- Using removal effects directly as credit. They overlap and add up to more than 100% (218.7% for Kesari), so scale them first.
- Defining states too finely. Splitting every campaign into its own state leaves many transitions with only a handful of observations.
- Reading the removal effect as a forecast. It is calculated inside the model. A holdout test is the way to check what happens when a channel is paused for real.
Key Takeaways
- A customer journey is a Markov chain: Start, channel touchpoints as transient states, and two absorbing states, Conversion and Null.
- Null paths are the "Left city" of marketing. They supply the drop-off probabilities that make the TPM meaningful, and most journeys end there (46,794 of Kesari's 50,000).
- The TPM is built the same way as in Part 2: count every move from Start to the ending, then divide by the row totals.
- The removal effect sends everyone who reaches a channel to Null and measures the fall in conversion probability. A channel scores highly when it sits on many converting routes, like Google Shopping in the six-journey example.
- Removal effects overlap, so they are scaled to add up to 100% before they are used as credit.
➡️ Up next: Part 6: Markov vs Rule-Based Attribution puts Markov credit next to last click, first touch, LNDC, linear and position-based on the same 50,000 journeys. It shows which gaps Markov closes and how to use it in a budget review.
Quick Quiz: Test Yourself
🧠 Test yourself: 5 questions (click to open)
1. In a Markov attribution model, what is a null path?
2. What goes wrong if a Markov model is built from converting journeys only?
3. In the six-journey example, each channel appears in two of the three conversion paths. Why does Google Shopping get the largest removal effect?
4. How is a channel "removed" when calculating its removal effect?
5. Kesari's six removal effects add up to 218.7%. What is the next step before using them as credit?
Unsure about a term? See the Markov Chain Attribution Jargon Checklist.
In case of any queries or feedback, feel free to drop a comment or reach out using the Contact section.