Cohort analysis in Digital Marketing - Time & Space Complexity
When performing cohort analysis, we want to understand how the time to analyze data changes as the number of users or time periods grows.
We ask: How does the work increase when we add more cohorts or more data points?
Analyze the time complexity of the following cohort analysis process.
// Assume cohorts is a list of user groups by signup date
// dataPoints is the number of time periods to analyze
for (let cohort of cohorts) {
for (let period = 0; period < dataPoints; period++) {
calculateMetric(cohort, period);
}
}
This code calculates a metric for each cohort over multiple time periods.
We have two loops repeating work:
- Primary operation: Calculating metrics for each cohort and time period.
- How many times: For each cohort, the inner loop runs once per time period, so total runs equal cohorts x dataPoints.
As we add more cohorts or more time periods, the total calculations grow by multiplying these two numbers.
| Input Size (cohorts x periods) | Approx. Operations |
|---|---|
| 10 cohorts x 5 periods | 50 calculations |
| 100 cohorts x 10 periods | 1,000 calculations |
| 1,000 cohorts x 20 periods | 20,000 calculations |
Pattern observation: Doubling cohorts or periods roughly doubles the work, so total work grows proportionally to both.
Time Complexity: O(n × m)
This means the time to complete cohort analysis grows proportionally with the number of cohorts and the number of time periods analyzed.
[X] Wrong: "The time only depends on the number of cohorts, not the time periods."
[OK] Correct: Each cohort's data is analyzed across all time periods, so ignoring periods misses a big part of the work.
Understanding how cohort analysis scales helps you explain data processing challenges clearly and shows you can think about efficiency in real marketing tasks.
"What if we only analyze a fixed number of recent time periods regardless of total data? How would that affect the time complexity?"
Practice
cohort analysis in digital marketing?Solution
Step 1: Understand cohort analysis definition
Cohort analysis groups users who share common characteristics to observe their behavior over time.Step 2: Identify the main goal in marketing context
This helps marketers see patterns like retention and engagement, which is not about random groups or competitor analysis.Final Answer:
To group users by shared traits and study their behavior over time -> Option AQuick Check:
Cohort analysis = Group users by traits and track behavior [OK]
- Confusing cohort analysis with random user grouping
- Thinking it only counts total visits
- Mixing it up with competitor analysis
Solution
Step 1: Identify cohort grouping criteria
Cohorts are defined by shared traits, such as the time of first purchase or signup.Step 2: Evaluate options for correct cohort definition
Only users who made their first purchase in the same month form a valid cohort; random clicks or single visits do not define cohorts.Final Answer:
Users who made their first purchase in the same month -> Option AQuick Check:
Cohort = users sharing a key event time [OK]
- Choosing random or one-time actions as cohorts
- Ignoring the shared time or event aspect
- Mixing different signup dates in one cohort
Month Joined | Month 0 | Month 1 | Month 2 January | 100 | 80 | 60 February | 120 | 90 | 70
Solution
Step 1: Identify initial users and retained users after 2 months
For January cohort, initial users (Month 0) = 100, users after 2 months (Month 2) = 60.Step 2: Calculate retention rate
Retention rate = (Users after 2 months / Initial users) * 100 = (60 / 100) * 100 = 60%.Final Answer:
60% retention after 2 months -> Option CQuick Check:
60/100 = 0.6 = 60% retention [OK]
- Using wrong month data for calculation
- Dividing initial users by retained users
- Confusing retention with total users
Solution
Step 1: Understand cohort grouping importance
Cohorts must have users sharing the same key trait, like signup month, to track behavior accurately over time.Step 2: Analyze impact of mixing different months
Mixing users from different months breaks this principle, leading to misleading retention and engagement data.Final Answer:
It breaks the cohort definition, causing inaccurate behavior tracking -> Option DQuick Check:
Mixing months breaks cohort accuracy [OK]
- Assuming mixing cohorts improves accuracy
- Ignoring impact on behavior tracking
- Thinking it only changes user count
Solution
Step 1: Define goal of analysis
The goal is to see how different campaigns impact retention over time.Step 2: Choose cohort grouping that matches goal
Grouping users by the campaign they first interacted with allows comparing retention per campaign monthly.Step 3: Evaluate other options
Grouping all users together or ignoring campaign data loses campaign-specific insights; analyzing only first month misses long-term trends.Final Answer:
Group users by the campaign they first interacted with and track retention monthly -> Option BQuick Check:
Group by campaign for retention impact analysis [OK]
- Ignoring campaign data in cohort grouping
- Mixing all users losing campaign insights
- Only checking short-term retention
Ready to prove it?
Pass the test and this pattern moves unknown
