Multi-channel attribution in Digital Marketing - Time & Space Complexity
When analyzing multi-channel attribution, we want to understand how the effort to assign credit to marketing channels grows as the number of channels and interactions increase.
We ask: How does the work needed change when more channels or customer touchpoints are involved?
Analyze the time complexity of the following simplified attribution calculation.
// For each customer journey
for journey in journeys:
# For each touchpoint in the journey
for touchpoint in journey.touchpoints:
# Assign credit to the channel
credit[touchpoint.channel] += calculate_credit(touchpoint)
This code assigns credit to each marketing channel by going through every touchpoint in every customer journey.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: Looping through each customer journey and then each touchpoint inside it.
- How many times: The inner loop runs once for every touchpoint in every journey, so total operations depend on total touchpoints across all journeys.
As the number of journeys and touchpoints grows, the total work grows roughly in proportion to the total touchpoints.
| Input Size (n = total touchpoints) | Approx. Operations |
|---|---|
| 10 | About 10 credit assignments |
| 100 | About 100 credit assignments |
| 1000 | About 1000 credit assignments |
Pattern observation: The work grows directly with the number of touchpoints; doubling touchpoints doubles the work.
Time Complexity: O(n)
This means the time to assign credit grows in a straight line with the total number of touchpoints processed.
[X] Wrong: "Adding more channels won't affect processing time much because we only assign credit once per journey."
[OK] Correct: Each channel appears in touchpoints, so more channels usually mean more touchpoints to process, increasing total work.
Understanding how the number of customer interactions affects processing time helps you explain how marketing data scales and why efficient attribution matters.
"What if we grouped touchpoints by channel first and then assigned credit? How would that change the time complexity?"