6 min read

How to Monitor DAU WAU MAU in Mixpanel

DAU, WAU, and MAU tell you whether your users are coming back. A declining DAU signals churn or a broken feature. Mixpanel bakes these metrics into its Retention and Segmentation reports, and you can pull them via API for automated dashboards.

Track Activity Events with the SDK

DAU/WAU/MAU tracking starts with an event that fires consistently when users engage. This event becomes the basis for counting active users.

Install Mixpanel and Initialize

Add the Mixpanel browser SDK to your app. Initialize it with your Project Token from Settings > Project Settings.

javascript
npm install mixpanel-browser

import mixpanel from 'mixpanel-browser';
mixpanel.init('YOUR_PROJECT_TOKEN');
mixpanel.identify('user-123'); // Optional: link to a user ID
Initialize once on app load. Identify users so Mixpanel can track them across sessions.

Create an Activity Event

Fire an event whenever a user does something meaningful—viewing content, submitting a form, or launching the app. Call this event consistently; Mixpanel counts unique users per day, week, or month.

javascript
// Track when a user engages
mixpanel.track('user_active', {
  'timestamp': Date.now(),
  'section': 'dashboard',
  'action': 'view_report'
});

// Fire on meaningful interactions
document.addEventListener('click', () => {
  mixpanel.track('user_active');
});

// Or after a key action
function submitForm() {
  // ... form logic ...
  mixpanel.track('user_active', { 'form': 'signup' });
}
Fire `user_active` from your main interaction handlers. Avoid firing on every single action—once per session or per minute is enough.

Track as an Automated Page View (Optional)

Or use Mixpanel's auto-track to capture page views automatically. This reduces manual instrumentation and ensures every page load counts as activity.

javascript
mixpanel.init('YOUR_PROJECT_TOKEN', {
  'track_pageview': true
});

// On each page navigation (e.g., in your router)
mixpanel.track_pageview();
Enable `track_pageview` to capture page loads automatically as your activity metric.
Tip: A user is "active" if they fire your event at least once in a day (DAU), week (WAU), or month (MAU). Be consistent—use the same event for all three metrics.

View DAU WAU MAU in the Mixpanel UI

The Retention report is the fastest way to see daily, weekly, and monthly active users. It groups users by cohort and shows return rates over time.

Open Retention and Select Your Event

In the Mixpanel UI, click Analysis > Retention. Select your activity event (e.g., user_active) as the Cohort Event. This defines who counts as "active."

javascript
// Once in the UI, you can export the report:
// Click the ... menu → Export → CSV
// Or use the Retention API endpoint:

const response = await fetch(
  'https://data.mixpanel.com/api/2.0/retention?',
  {
    method: 'GET',
    headers: {
      'Authorization': `Bearer YOUR_SERVICE_ACCOUNT_TOKEN`,
      'Accept': 'application/json'
    }
  }
);
The Retention report shows cohorts (new users on date X) and their return rates. Export or query via API.

Set Retention Interval (Day/Week/Month)

Choose the Retention interval: Day for DAU, Week for WAU, Month for MAU. The chart shows what percentage of users from each cohort came back.

javascript
// Or use Segmentation for a faster snapshot:
// Go to Analysis > Segmentation
// Select your activity event
// Set "View by" to "Day" (or Week/Month)
// Set the date range
// This gives you unique user counts per day without cohorts

const segmentationQuery = {
  'event': 'user_active',
  'from_date': '2024-01-01',
  'to_date': '2024-01-31',
  'interval': 1, // 1 day
  'unit': 'day'
};

const data = await queryMixpanelSegmentation(segmentationQuery);
Segmentation gives you daily active user counts directly; Retention shows cohort trends.

Export or Save as a Board

Once you have the metrics, save the report to a Board for quick access, or export to CSV. Boards let you view DAU/WAU/MAU trends over time without regenerating the report.

javascript
// In the Mixpanel UI, click 'Save' to add to a Board
// Or export the data:

const csvExport = document.querySelector('[data-export-csv]');
if (csvExport) {
  csvExport.click(); // Programmatically trigger export
}

// Then parse and store the CSV in your database or visualization tool
Save reports to Boards for one-click access to DAU/WAU/MAU trends.
Watch out: Retention counts a user as "returning" if they had *any* activity in the return window. If a user logs in on Monday and Friday, they count as 1 DAU on each day, but only 1 WAU for that week.

Automate Metrics with the Mixpanel API

To pipe DAU/WAU/MAU into your own dashboard, database, or alerting system, use the Data Export API with a scheduled job.

Get Your Service Account Token

Create a Service Account in Settings > Service Accounts to avoid rate limits. Copy the Access Token and store it securely as an environment variable.

javascript
const serviceAccountToken = process.env.MIXPANEL_SERVICE_ACCOUNT_TOKEN;
const projectId = process.env.MIXPANEL_PROJECT_ID;

const headers = {
  'Authorization': `Bearer ${serviceAccountToken}`,
  'Accept': 'application/json'
};

console.log('Service account authenticated for Mixpanel API');
Store tokens in environment variables; never hardcode them.

Query Active Users via Events API

Use the Events API to count unique users for a date range. Request daily, weekly, or monthly aggregates by adjusting the date range.

javascript
async function getActiveUsers(eventName, fromDate, toDate) {
  const url = `https://data.mixpanel.com/api/2.0/events?` +
    new URLSearchParams({
      'from_date': fromDate,
      'to_date': toDate,
      'interval': 1,
      'event': eventName
    });

  const response = await fetch(url, { headers });
  const data = await response.json();
  
  // data.data contains time-series of event counts
  return data.data;
}

// Get DAU for today
const today = '2024-01-15';
const dau = await getActiveUsers('user_active', today, today);
console.log('DAU:', dau);
The Events API returns unique users per day. Query a 7-day range for WAU, 30-day for MAU.

Store Metrics and Alert on Drops

Save the metrics to your database or send alerts if DAU drops below a threshold. Run this job daily or weekly via cron.

javascript
async function monitorMetrics() {
  const today = new Date().toISOString().split('T')[0];
  const weekAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000)
    .toISOString().split('T')[0];
  const monthAgo = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000)
    .toISOString().split('T')[0];

  const dau = await getActiveUsers('user_active', today, today);
  const wau = await getActiveUsers('user_active', weekAgo, today);
  const mau = await getActiveUsers('user_active', monthAgo, today);

  const metrics = { dau, wau, mau, timestamp: new Date() };
  await saveToDatabase(metrics);

  if (dau < 100) {
    await sendSlackAlert(`⚠️ DAU dropped to ${dau}. Check tracking.`);
  }
}

// Run daily
setInterval(monitorMetrics, 24 * 60 * 60 * 1000);
Check metrics daily and alert on anomalies to catch churn or broken tracking early.
Tip: Cache API results for 1 hour to avoid rate limits. Mixpanel's Data Export API has limits on free plans; use Service Accounts for unlimited requests.

Common Pitfalls

  • Mixing event counts with active users. A user who does 5 actions fires 5 events but counts as 1 DAU. Don't confuse volume with unique user count.
  • Not filtering out internal traffic. QA, employees, and bots inflate your metrics. Create a Cohort to exclude them, then apply it to Retention reports.
  • Switching event definitions mid-way. If you track page_view for January and user_active for February, the metrics won't be comparable. Lock the event definition.
  • Ignoring timezone misalignment. Mixpanel defaults to UTC. If your users span timezones, a "daily" user might actually span two calendar days. Adjust reports or add timezone as a property.

Wrapping Up

You can now monitor DAU, WAU, and MAU directly in Mixpanel's UI via Retention reports, or pull them programmatically via the Data Export API. Set up daily or weekly checks to catch user growth trends or churn before it's too late. If you want to track and correlate DAU, WAU, and MAU across all your tools in one place, Product Analyst can help.

Track these metrics automatically

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

Try Product Analyst — Free