Attribution models (last-click, multi-touch) in Digital Marketing - Time & Space Complexity
When analyzing attribution models, we want to understand how the effort to assign credit grows as the number of customer interactions increases.
How does the time to calculate attribution change when more touchpoints are involved?
Analyze the time complexity of the following simplified attribution calculation.
function calculateAttribution(touchpoints) {
let credit = {};
for (let i = 0; i < touchpoints.length; i++) {
let channel = touchpoints[i];
credit[channel] = (credit[channel] || 0) + 1;
}
return credit;
}
This code counts how many times each marketing channel appears in a customer's journey.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: Looping through each touchpoint once.
- How many times: Exactly once per touchpoint in the journey.
As the number of touchpoints grows, the time to assign credit grows proportionally.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | 10 steps to count channels |
| 100 | 100 steps to count channels |
| 1000 | 1000 steps to count channels |
Pattern observation: Doubling touchpoints doubles the work needed.
Time Complexity: O(n)
This means the time to calculate attribution grows directly with the number of touchpoints.
[X] Wrong: "Attribution calculation time stays the same no matter how many touchpoints there are."
[OK] Correct: Each touchpoint must be checked to assign credit, so more touchpoints mean more work.
Understanding how attribution calculations scale helps you explain data processing in marketing tools clearly and confidently.
What if we changed the model to assign credit only to the last touchpoint? How would the time complexity change?