Retention analysis shows which users come back and when they stop returning. It's the difference between a spike in signups and a sustainable product. In Amplitude, you need to define your initial cohort and the action that defines 'returning,' then the platform calculates retention windows for you.
Set Up Event Tracking
Retention analysis starts with events. You need at least two: an initial event that defines your cohort and a returning action that proves engagement.
Log your initial event when users sign up or onboard
This event marks the start of a cohort. Use the Amplitude SDK to log a named event at the moment a user qualifies. For example, track when they complete onboarding or first use a key feature. Make sure you're logging this consistently for all users.
const amplitude = Amplitude.getInstance();
amplitude.logEvent('Onboarding Complete', {
userId: user.id,
plan_tier: user.planTier,
signup_source: user.source
});Log a returning action event to measure engagement
This is the event you'll watch for in retention windows. Common returning actions are logins, feature usage, or API calls. The event should represent genuine engagement—not passive triggers like emails received.
amplitude.logEvent('Dashboard Viewed', {
userId: user.id,
dashboard_id: dashboardId,
data_points_queried: data.length
});Build a Retention Chart in Amplitude
Once events are flowing, use Amplitude's Retention tab to analyze cohorts and returning actions across time windows.
Navigate to the Retention section and select your initial event
In the Amplitude webapp, click Analyze > Retention. This opens the retention chart interface. Under Initial Event, select the event that starts your cohort (e.g., Onboarding Complete). Amplitude will show the size of your cohort and when it began.
// Example: Using Amplitude's REST API to fetch retention data
const options = {
method: 'POST',
headers: {
'Authorization': `Bearer ${YOUR_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
e: [{'event_type': 'Onboarding Complete'}],
i: 1,
m: 'uniques',
interval: 1,
interval_unit: 'day',
retention_type: 'event'
})
};
fetch('https://amplitude.com/api/2/retention', options)
.then(res => res.json())
.then(data => console.log(data));Set the returning action and specify retention windows
Under Returning Action, select the event that proves a user returned (e.g., Dashboard Viewed). By default, Amplitude shows Day 0, Day 7, Day 14, and Day 30. You can adjust the interval from days to weeks or months depending on your product cycle.
// Set user properties before logging events to enable cohort segmentation
amplitude.setUserProperties({
plan_tier: 'pro',
signup_source: 'organic',
company_size: 'mid-market',
onboarding_path: 'self-serve'
});
// Events logged after this will inherit these properties for retention segmentation
amplitude.logEvent('Dashboard Viewed');Segment and Act on Retention Data
Raw retention numbers are useful, but segmented retention tells you which user types stick around and which don't.
Add user property filters to segment your retention curve
In the retention chart, click + Add Filter and select a user property like plan_tier or signup_source. This breaks down retention by segment so you can see if premium users or organic signups have better retention. This reveals which customer segments are more engaged.
// Query Amplitude's API to fetch retention data segmented by user property
const retentionQuery = {
method: 'POST',
headers: {
'Authorization': `Bearer ${YOUR_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
e: [{'event_type': 'Onboarding Complete'}],
ret_event: [{'event_type': 'Dashboard Viewed'}],
segment: [{'group': 'plan_tier', 'values': ['pro', 'basic']}],
interval: 1,
interval_unit: 'day'
})
};
fetch('https://amplitude.com/api/2/retention', retentionQuery)
.then(res => res.json())
.then(data => console.log('Retention by tier:', data));Create a cohort of high-retainers and export for downstream use
If you find that users from a certain segment have high retention, create an Amplitude cohort of those users. Go to Cohorts, create a new cohort, and define it by the segments you identified (e.g., 'pro users who returned by Day 7'). Export this cohort to email, CRM, or data warehouse tools.
// Query Amplitude's Cohorts API to check cohort size
const getCohort = async (cohortId) => {
const response = await fetch(`https://amplitude.com/api/2/cohort/${cohortId}`, {
method: 'GET',
headers: {
'Authorization': `Bearer ${YOUR_API_KEY}`,
'Content-Type': 'application/json'
}
});
const cohort = await response.json();
console.log(`Cohort has ${cohort.size} users, estimated last modified: ${cohort.last_modified}`);
return cohort;
};
getCohort('HIGH_RETAINERS_DAY7');Common Pitfalls
- Selecting an initial event that's too common (like 'Page View') instead of a meaningful milestone—this blurs your cohorts and makes retention hard to interpret.
- Forgetting to backfill historical events before you set up retention—new events only count forward, so retention analysis is limited to users who triggered the event after tracking was enabled.
- Not accounting for time zones—Amplitude's retention windows are based on UTC unless your project is configured otherwise, which can cause off-by-one mismatches in your cohort boundaries.
- Measuring retention on a returning action that's also logged accidentally or passively (like a heartbeat ping or auto-save event)—this inflates retention numbers and masks real churn.
Wrapping Up
With Amplitude's retention charts, you now have visibility into which users return and which don't. Start by segmenting by plan tier or acquisition source to find your stickiest cohorts, then work backward to understand why they return. If you want to set up retention tracking across multiple tools and sync retention data to your data warehouse, Product Analyst can help.