6 min read

How to Calculate User Stickiness in Amplitude

User stickiness tells you whether people are actually coming back. Amplitude gives you two main paths: calculate DAU/MAU ratio (quick, broad signal) or analyze retention cohorts (precise, shows where users drop). Most teams obsess over one metric—Day 7 Retention—because it predicts long-term engagement better than anything else.

Calculate DAU/MAU Ratio Using the HTTP API

The simplest stickiness metric is Daily Active Users divided by Monthly Active Users. A 0.30 DAU/MAU ratio means 30% of your monthly users are active on any given day. It's a rough signal, but useful for spotting trends.

Step 1: Get your API credentials from Amplitude Settings

Go to Settings > API Keys in Amplitude. Copy your API Key and Secret Key—you'll use these to authenticate HTTP requests. Keep the secret key private; treat it like a password.

javascript
const apiKey = process.env.AMPLITUDE_API_KEY;
const secretKey = process.env.AMPLITUDE_SECRET_KEY;

// Encode credentials for Basic Auth
const credentials = Buffer.from(`${apiKey}:${secretKey}`).toString('base64');

Step 2: Query the /events endpoint for daily active users

Use Amplitude's HTTP API to fetch aggregated event data. Specify a date range and Amplitude returns event counts. To calculate active users, group by user_id and count unique users per day.

javascript
async function getDailyActiveUsers(date) {
  const url = `https://amplitude.com/api/2/events?start=${date}&end=${date}`;
  
  const response = await fetch(url, {
    headers: {
      'Authorization': `Basic ${credentials}`
    }
  });
  
  const data = await response.json();
  
  // Count unique user_ids in the response
  const uniqueUsers = new Set(data.data.map(event => event.user_id));
  return uniqueUsers.size;
}

const dau = await getDailyActiveUsers('20260326');
console.log(`Daily Active Users: ${dau}`);

Step 3: Calculate monthly unique users and compute the ratio

Expand your date range to a full month. Loop through daily requests or use Amplitude's batch query to aggregate. Divide DAU by MAU to get your stickiness ratio.

javascript
async function getMonthlyActiveUsers(startDate, endDate) {
  const uniqueUsers = new Set();
  
  const response = await fetch(
    `https://amplitude.com/api/2/events?start=${startDate}&end=${endDate}`,
    {
      headers: {
        'Authorization': `Basic ${credentials}`
      }
    }
  );
  
  const data = await response.json();
  data.data.forEach(event => {
    uniqueUsers.add(event.user_id);
  });
  
  return uniqueUsers.size;
}

const mau = await getMonthlyActiveUsers('20260301', '20260331');
const dau = await getDailyActiveUsers('20260326');

const stickinessRatio = (dau / mau * 100).toFixed(1);
console.log(`Stickiness (DAU/MAU): ${stickinessRatio}%`);
Tip: Monitor DAU/MAU weekly, not daily—daily noise obscures real trends. Watch out: If your app sends background notifications that trigger events without user action, you'll inflate DAU. Define active as intentional user action (tap, click, form submit) to avoid false positives.

Track Retention Cohorts for Precision Stickiness Metrics

DAU/MAU is directional, but Day 7 Retention—the percentage of users who return 7 days after signup—is predictive. Amplitude calculates this automatically in the Retention view. It's the metric teams actually watch.

Step 1: Set up a Retention cohort in Amplitude's dashboard

Go to Analytics > Retention. Set Starting Event (e.g., "First App Open" or "Signed Up") and Returning Event (e.g., "Page View," "Engagement Event," or a custom action). Amplitude buckets users by signup date and calculates return rates for Day 1, 7, 14, 30, etc.

javascript
// Track startup and engagement events for retention analysis
import * as amplitude from '@amplitude/analytics-browser';

amplitude.init('YOUR_API_KEY');

// Log signup event (starting point for cohort)
amplitude.track('Signed Up', {
  plan_type: 'free',
  signup_source: 'landing_page'
});

// Later: track engagement or return visits
amplitude.track('User Opened App', {
  app_version: '2.1.0'
});

Step 2: Fetch retention data programmatically via the Cohort API

Amplitude's Cohort API lets you query retention data for all cohorts. Returns return rates by interval (Day 1, Day 7, Day 30, etc.). Parse the response to extract Day 7 retention specifically.

javascript
async function getRetentionForCohorts() {
  const url = 'https://amplitude.com/api/2/cohorts';
  
  const response = await fetch(url, {
    headers: {
      'Authorization': `Basic ${credentials}`
    }
  });
  
  const cohorts = await response.json();
  
  // cohorts.data contains all user cohorts
  const retentionMetrics = {};
  
  cohorts.data.forEach(cohort => {
    retentionMetrics[cohort.id] = {
      size: cohort.size,
      created_date: cohort.created_date
    };
  });
  
  return retentionMetrics;
}

const retention = await getRetentionForCohorts();

Step 3: Extract and monitor Day 7 Retention as your primary stickiness KPI

Calculate the average Day 7 retention across recent cohorts. This is your headline stickiness metric. Set a baseline (e.g., 30%) and alert if it drops 10% or more—it's a leading indicator of engagement decay.

javascript
// Fetch detailed retention intervals for a specific date range
async function getDay7RetentionRate(startDate, endDate) {
  const url = `https://amplitude.com/api/2/retention?start=${startDate}&end=${endDate}`;
  
  const response = await fetch(url, {
    headers: {
      'Authorization': `Basic ${credentials}`
    }
  });
  
  const data = await response.json();
  
  // Extract Day 7 return rates from each cohort
  const day7Rates = data.data.map(cohort => ({
    cohort_date: cohort.date,
    day7_return_rate: cohort.retention_table[7] || 0  // Day 7 is index 7
  }));
  
  const avgDay7 = day7Rates.reduce((sum, item) => sum + item.day7_return_rate, 0) / day7Rates.length;
  
  console.log(`Average Day 7 Retention: ${(avgDay7 * 100).toFixed(1)}%`);
  
  if (avgDay7 < 0.30) {
    console.warn('⚠️  Day 7 retention below 30% — investigate onboarding or recent changes');
  }
  
  return avgDay7;
}

const day7 = await getDay7RetentionRate('20260301', '20260331');
Tip: Day 7 retention changes slowly—look for month-over-month trends, not week-to-week fluctuations. A 5% drop that persists for 2+ weeks is a real signal. Watch out: Amplitude's retention counts any event as a "return." If you're logging noisy events (analytics pings, background syncs), your retention numbers will be artificially high. Define a clean returning event: a real user action, not a system event.

Common Pitfalls

  • Mixing signup cohort date with first activity date—Amplitude segments by when the user first appears in your data, not when they completed your signup flow. If you delay event tracking by hours, your cohorts shift.
  • Forgetting that Day 1 = same day—if someone signs up at 11 PM and opens the app at midnight, that's Day 2, not Day 1. A common source of confusion when benchmarking.
  • Using raw event counts instead of unique user counts for DAU/MAU—Amplitude's events endpoint returns events, not users. You must deduplicate by user_id to avoid counting the same person 10 times.
  • Not excluding internal traffic—if your team or QA users are active daily, your DAU will be artificially inflated. Use Settings > Manage Users to exclude test accounts, or filter them in your API queries.

Wrapping Up

User stickiness is the truest measure of product engagement. Amplitude makes it straightforward: DAU/MAU for a quick pulse, Day 7 Retention for precision. Most teams watch Day 7 religiously—a 5% drop is an early warning sign. Run these calculations weekly, plot them on a dashboard, and alert when they trend down. If you want to track stickiness automatically across your analytics tools and get alerts when it drops, Product Analyst can help.

Track these metrics automatically

Product Analyst connects to your stack and surfaces the insights that matter.

Try Product Analyst — Free