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.
npm install mixpanel-browser
import mixpanel from 'mixpanel-browser';
mixpanel.init('YOUR_PROJECT_TOKEN');
mixpanel.identify('user-123'); // Optional: link to a user IDCreate 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.
// 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' });
}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.
mixpanel.init('YOUR_PROJECT_TOKEN', {
'track_pageview': true
});
// On each page navigation (e.g., in your router)
mixpanel.track_pageview();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."
// 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'
}
}
);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.
// 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);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.
// 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 toolAutomate 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.
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');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.
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);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.
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);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_viewfor January anduser_activefor 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.