6 min read

How to Set Up Alerts for Event Frequency in Mixpanel

You need to know when checkout events drop by half overnight. Or when your sign-up flow suddenly breaks and nobody's converting. Waiting until someone complains is too late. Mixpanel alerts watch event frequency in real-time and notify your team the moment something shifts outside your normal range.

Getting Events Into Mixpanel

Before you can alert on event frequency, you need consistent event tracking flowing into your project. This is the foundation everything else depends on.

Step 1: Install and initialize the Mixpanel SDK

If you're working in a web app, add the Mixpanel JavaScript SDK and initialize it with your project token. You can find your token in Project Settings. Initialize it as early as possible so tracking starts immediately when the page loads.

javascript
import mixpanel from 'mixpanel-browser';

mixpanel.init('YOUR_PROJECT_TOKEN', {
  debug: true,
  track_pageview: true,
  persistence: 'localStorage'
});

console.log('Mixpanel initialized:', mixpanel.get_distinct_id());
Initialize once at app startup, not on every page load

Step 2: Track the events you'll monitor

Use mixpanel.track() to send events whenever a user completes an action you care about. Each event gets a name and optional properties. For alerts on event frequency, you only need the event name — properties are just for context.

javascript
// Track a critical user action
mixpanel.track('Checkout Completed', {
  'revenue': 99.99,
  'currency': 'USD',
  'product_id': 'sku-12345',
  'timestamp': new Date().getTime()
});

// Track another important event
mixpanel.track('Feature Enabled', {
  'feature_name': 'advanced_reporting',
  'user_tier': 'premium'
});
Send these events from pages or actions that matter for your business

Step 3: Verify events are arriving in Mixpanel

Go to Events in your Mixpanel dashboard. You should see your events listed with live event counts updating in real-time. If nothing appears after 30 seconds, check that your token is correct and that the tracking code is actually executing (use browser DevTools to confirm).

Tip: Set track_pageview: true in your init config to automatically track page views as events. This gives you a baseline for site health alerting.

Setting Up Alerts Through the UI

The easiest way to create your first alert is through Mixpanel's web interface. Navigate to Events, pick the event you want to monitor, and configure thresholds.

Step 1: Navigate to the Events view

Click Events in the left sidebar of your Mixpanel project. You'll see all events tracked in the last 7 days, ranked by event count. Scroll to find the event you want to alert on — or search by event name.

Step 2: Open the alert menu for your event

Click on the event name or the menu icon (three dots) next to it. Select Create Alert. You'll see a form where you define the alert condition, threshold, and notification channels.

Step 3: Configure the frequency threshold

Set the alert type to Frequency. Choose your condition: drops below (most common for catching problems), exceeds (for unexpected traffic spikes), or changes by (for percentage-based deviation). Enter a number and time window. For example, alert if *Checkout Completed* drops below 20 events per hour.

javascript
// Example event that triggers your frequency alert
function onCheckoutComplete(orderData) {
  mixpanel.track('Checkout Completed', {
    'order_id': orderData.id,
    'amount': orderData.total,
    'payment_method': orderData.method,
    'success': true
  });
}

// If this stops being called 20+ times per hour, the alert fires
onCheckoutComplete({ id: '12345', total: 99.99, method: 'card' });
This event will be monitored by your frequency threshold

Step 4: Choose notification channels

Select Email, Slack, or both. Add team member emails or select a Slack workspace and channel. Mixpanel will send the alert when the condition is triggered, then repeat notifications at intervals you set (e.g., every 2 hours if the condition persists).

Step 5: Save and test

Click Save Alert. Mixpanel will activate it immediately. To test, temporarily stop sending the event (or send fewer than your threshold) to trigger the alert. Check your email or Slack for the notification.

Watch out: Don't set thresholds too tight. A high-volume event (10k+ per hour) has natural variation; a 5% dip isn't an outage. Start with larger drops (e.g., 50% below baseline) and tighten over time.

Automating Alerts With the API

If you manage many events or need to programmatically create and update alerts, the Mixpanel API lets you do this without touching the UI.

Step 1: Get your authentication credentials

Go to Project Settings > Access Keys. Copy your Project Token and your Service Account Secret (if you have API access enabled). These authenticate requests to the Mixpanel API.

Step 2: Create an alert via the REST API

POST to Mixpanel's alerts endpoint with your event name, threshold condition, and notification settings. Include basic auth headers with your service account secret and a colon as the password.

javascript
const projectToken = 'YOUR_PROJECT_TOKEN';
const serviceSecret = 'YOUR_SERVICE_ACCOUNT_SECRET';
const auth = btoa(serviceSecret + ':');

const alertPayload = {
  event: 'Checkout Completed',
  type: 'frequency',
  operator: 'less_than',
  threshold: 20,
  time_window: 'hour',
  notify_emails: ['[email protected]'],
  notify_slack: 'C1234567890'
};

fetch(`https://api.mixpanel.com/events/alerts?project_token=${projectToken}`, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Basic ' + auth
  },
  body: JSON.stringify(alertPayload)
})
  .then(res => res.json())
  .then(data => {
    if (data.alert_id) {
      console.log('Alert created with ID:', data.alert_id);
    } else {
      console.error('Failed to create alert:', data.error);
    }
  });
The API returns the alert_id so you can update or delete it later

Step 3: Test the alert by reducing event frequency

Send fewer events than your threshold to verify the alert triggers. Check your email inbox or Slack channel for the notification. If nothing arrives after 5 minutes, verify your webhook URL or email address is correct.

javascript
// Simulate a checkout event drop to test your alert
function simulateCheckoutDrop() {
  // Only send 5 checkout events (below your threshold of 20/hour)
  for (let i = 0; i < 5; i++) {
    mixpanel.track('Checkout Completed', {
      'order_id': 'test-' + i,
      'amount': Math.random() * 100
    });
  }
}

// Call once to trigger the alert
simulateCheckoutDrop();
This sends fewer events than your threshold to test the alert mechanism
Tip: Use the API to bulk-create alerts across all your critical events. Script it once, then reuse it when onboarding to a new Mixpanel workspace.

Common Pitfalls

  • Setting thresholds based on peak hours. Your checkout rate at 2 AM is different from 2 PM. Use an average of typical business hours, not your absolute max.
  • Alerting on too many events. You'll get alert fatigue and stop paying attention. Focus on events that directly impact revenue or user experience.
  • Not setting a time window. Mixpanel needs to know if you're comparing the last hour to the last day. Without it, your alert may misfire or not trigger when it should.
  • Forgetting to test before going live. Create the alert, manually reduce event frequency, and verify notifications work. The last thing you want is to find out your alert is broken when a real outage happens.

Wrapping Up

Event frequency alerts give you visibility into whether critical user actions are working or broken. Set them on checkout, sign-ups, and other revenue-driving events, test them once, and let Mixpanel watch your back. If you want to track this automatically across Mixpanel and other tools without manual setup each time, Product Analyst can help.

Track these metrics automatically

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

Try Product Analyst — Free