5 min read

How to Visualize DAU MAU Ratio in Amplitude

Your DAU/MAU ratio tells you whether users are coming back. If 40% of your monthly users are active today, you're getting loyal engagement—but if it's 5%, users aren't returning. Amplitude can show you this ratio directly in your dashboard, and you can calculate it programmatically via the API.

Verify User Tracking with the Amplitude SDK

Before visualizing DAU/MAU, confirm that Amplitude is tracking unique users correctly. You need user_id set consistently for every event.

Initialize the Amplitude SDK with a persistent user_id

Set up the JavaScript SDK in your app and identify users on login. Amplitude uses user_id to count unique daily and monthly active users. This value must persist across sessions.

javascript
import * as amplitude from '@amplitude/analytics-browser';

amplitude.init('YOUR_API_KEY', {
  userId: currentUser.id
});

// Track events with the user context
amplitude.track('page_view', {
  page: 'dashboard'
});
Initialize Amplitude with a persistent user_id to enable accurate DAU/MAU counting

Handle logged-in and anonymous users

Set user_id when the user logs in. For anonymous users, Amplitude falls back to device_id. If a user logs in later, call setUserId() to consolidate their sessions.

javascript
// On login
if (user && user.id) {
  amplitude.setUserId(user.id);
}

// On logout
amplitude.setUserId(null);  // Clear user context

Verify tracking in the Amplitude dashboard

Go to Analytics > User Sessions, search for a known user by their ID, and confirm their events appear. Check the User Lookup tab for the most recent event timestamp.

Watch out: If you're only using device_id, Amplitude counts an anonymous visitor and the same logged-in user as two separate monthly users, inflating MAU.

Create a DAU/MAU Visualization in Your Dashboard

Amplitude's Users chart automatically counts daily and monthly active users. You can overlay both on the same chart to see engagement trends.

Add a Users chart to track active users

Click + Add Chart and select Users. Set the Time Window to at least 30 days to capture a full monthly baseline. Leave Event blank to count all active users regardless of which events they trigger.

Add a second series for monthly baseline

In the chart, click + Add Series and select Users again. Set the first series to group by Day and the second by Month. This lets you compare daily peaks against the monthly baseline.

javascript
// After building the chart in Amplitude UI, pull the data via API
const API_KEY = process.env.AMPLITUDE_API_KEY;
const SECRET_KEY = process.env.AMPLITUDE_SECRET_KEY;
const auth = Buffer.from(`${API_KEY}:${SECRET_KEY}`).toString('base64');

const response = await fetch(
  'https://api.amplitude.com/api/2/events?start=2024-03-01&end=2024-03-31&limit=10000',
  { headers: { 'Authorization': `Basic ${auth}` } }
);

const data = await response.json();
console.log('Events:', data.data.events.length);

Segment by user properties if needed

Click + Add Filter and select a Cohort or event property (e.g., plan_type, country) to compare DAU/MAU across customer segments. This reveals whether engagement differs between free and paid users.

Tip: MAU is always ≥ DAU, so your ratio never exceeds 100%. If it approaches 100%, nearly all monthly users are active every day—investigate whether this is normal for your product or if it signals an issue with your tracking.

Calculate DAU/MAU Programmatically with the REST API

For automated reporting or external dashboards, query the Amplitude Events API to fetch user counts and calculate the ratio yourself.

Query the Amplitude Events API for a date range

Use the Events API with date parameters to export all events for a month. Parse the response to extract unique user_id values per day and for the entire period.

javascript
const axios = require('axios');

const API_KEY = process.env.AMPLITUDE_API_KEY;
const SECRET_KEY = process.env.AMPLITUDE_SECRET_KEY;
const auth = Buffer.from(`${API_KEY}:${SECRET_KEY}`).toString('base64');

const response = await axios.get('https://api.amplitude.com/api/2/events', {
  params: {
    start: '2024-03-01',
    end: '2024-03-31',
    limit: 10000
  },
  headers: { 'Authorization': `Basic ${auth}` }
});

const events = response.data.data.events;
console.log(`Fetched ${events.length} events`);

Aggregate users by day and month

Count unique user_id values for each day and the entire month using a Set. This gives you the daily and monthly active user counts.

javascript
const dailyUsers = new Map();  // YYYY-MM-DD -> Set of user_ids
const monthlyUsers = new Set();

for (const event of events) {
  const date = event.event_time.split('T')[0];  // Extract date
  const userId = event.user_id;

  if (!dailyUsers.has(date)) {
    dailyUsers.set(date, new Set());
  }
  dailyUsers.get(date).add(userId);
  monthlyUsers.add(userId);
}

const lastDay = '2024-03-31';
const dau = dailyUsers.get(lastDay)?.size || 0;
const mau = monthlyUsers.size;

console.log(`DAU (${lastDay}): ${dau}`);
console.log(`MAU (Mar 2024): ${mau}`);
console.log(`Ratio: ${((dau / mau) * 100).toFixed(1)}%`);
Watch out: The Amplitude API has rate limits (600 requests/hour). Cache results and paginate through large datasets to avoid throttling.

Common Pitfalls

  • Counting device_id instead of user_id inflates MAU—an anonymous session plus the same logged-in user counts as two users
  • Defining MAU inconsistently (rolling 30 days vs calendar month) makes month-to-month comparisons meaningless
  • Forgetting to exclude test accounts and internal team activity will skew your ratio lower
  • Using a chart time window shorter than 30 days makes MAU artificially low relative to DAU

Wrapping Up

DAU/MAU tells you if users are staying engaged. Use Amplitude's Users chart to visualize both metrics side-by-side, then query the API if you need automated reporting. If you want to track this metric across multiple tools and dig into what's driving engagement changes, Product Analyst can help.

Track these metrics automatically

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

Try Product Analyst — Free