5 min read

How to Monitor Event Frequency in Amplitude

If users are suddenly clicking a feature less, or your app is generating unexpected event spikes, you need to know immediately. Amplitude lets you monitor event frequency without building a separate monitoring system—track patterns through your dashboard, set alerts, and query the REST API for automated checks.

Track Events with the JavaScript SDK

Consistent event tracking is the foundation for monitoring frequency. You can't measure what you don't capture.

Initialize the SDK and log events

Install the Amplitude JavaScript SDK and initialize it with your API key. Then call logEvent() whenever users perform actions. Amplitude automatically timestamps each event and stores it, so you can measure how often each action occurs over time.

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

// Initialize at app startup
amplitude.init('YOUR_API_KEY');

// Log events as users interact
amplitude.logEvent('Payment_Processed', {
  currency: 'USD',
  amount: 4999,
  plan_tier: 'professional'
});

amplitude.logEvent('Dashboard_Loaded', {
  load_time_ms: 1240,
  user_segment: 'power_user'
});
Each logEvent() call becomes a timestamped record. Amplitude aggregates these to show frequency trends.

Use consistent, descriptive event names

Don't log the same action as payment_processed, Payment_Processed, and process_payment. Amplitude is case-sensitive and treats these as separate events. Pick a naming convention and enforce it. Include context in event properties (amount, plan tier, error type) so you can slice frequency by those dimensions later.

Set user ID early for accurate user attribution

Call setUserId() after authentication so Amplitude attributes events to the right user. Without it, Amplitude uses device ID, which creates duplicate frequency counts when a user logs in from multiple devices.

Tip: Log events immediately when they happen—don't batch them. Timing matters for accurate frequency analysis.

Monitor Frequency in the Amplitude Dashboard

Once events arrive, the Amplitude dashboard shows frequency trends in real time. This is your first line of detection for unusual behavior.

Create a chart to visualize event counts

Go to Analytics > Dashboards and click New Chart. Select Events as your metric and choose the event you want to track (e.g., Payment_Processed). Amplitude renders a line chart showing event count over time. Immediately you can spot if frequency drops, spikes, or stays flat.

Break down frequency by properties

Click Breakdown on your chart to split frequency by a user property (plan tier, country, signup date) or event property (payment method, currency). This isolates which segments have unusual frequency patterns. A global frequency drop might actually be a single segment losing traction.

Configure alerts for threshold breaches

Below your chart, enable Alerts. Set rules like 'Alert if daily Payment_Processed count drops below 10' or 'Alert if Feature_View spikes above 500 per hour'. Amplitude will send notifications to Slack, email, or a webhook when conditions are met.

javascript
// Example: fetch daily event counts via REST API for custom alerting
async function checkEventFrequency(eventName) {
  const now = Date.now();
  const oneDayAgo = now - (24 * 60 * 60 * 1000);
  
  const response = await fetch('https://api.amplitude.com/2/events', {
    method: 'GET',
    headers: {
      'Authorization': `Bearer YOUR_API_KEY`
    },
    body: JSON.stringify({
      event: eventName,
      start_time: oneDayAgo,
      end_time: now
    })
  });
  
  const data = await response.json();
  return data.series[0]?.data || [];
}

const counts = await checkEventFrequency('Payment_Processed');
const lastValue = counts[counts.length - 1];
if (lastValue < 10) {
  // Send alert to your system
  console.error('Payment frequency below threshold:', lastValue);
}
For production monitoring, combine dashboard alerts with API queries to cover edge cases and integrate with your own alerting system.
Watch out: Amplitude stores raw event data for 30 days by default. For long-term frequency trends (6+ months), export data to Snowflake or BigQuery periodically so you don't lose historical context.

Query Frequency Programmatically with the REST API

For automated monitoring and integration with your own systems, use the REST API to pull frequency data directly.

Query aggregated event counts by time

Use the Amplitude REST API's /events endpoint to fetch event counts for a custom time range. Pass the event name, start time, and end time (as Unix timestamps in milliseconds), and Amplitude returns total event count and breakdowns.

Set up a daily cron job to monitor frequency

Write a scheduled function that runs once per day. Query yesterday's event count, compare it to the day before, and alert if it deviates by more than a threshold (e.g., 20% drop). Store the results in a spreadsheet or database so you can analyze trends and detect patterns.

javascript
import fetch from 'node-fetch';

const monitorEventFrequency = async (eventName, threshold = 0.2) => {
  const now = new Date();
  const yesterday = new Date(now.getTime() - 24 * 60 * 60 * 1000);
  const twoDaysAgo = new Date(yesterday.getTime() - 24 * 60 * 60 * 1000);
  
  const getCount = async (start, end) => {
    const response = await fetch('https://api.amplitude.com/2/events', {
      method: 'POST',
      headers: {
        'Authorization': `Bearer YOUR_API_KEY`,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        event: eventName,
        start_time: start.getTime(),
        end_time: end.getTime()
      })
    });
    const data = await response.json();
    return data.data?.total || 0;
  };
  
  const yesterdayCount = await getCount(yesterday, now);
  const twoDaysAgoCount = await getCount(twoDaysAgo, yesterday);
  
  const changeRatio = (yesterdayCount - twoDaysAgoCount) / twoDaysAgoCount;
  if (Math.abs(changeRatio) > threshold) {
    const direction = changeRatio > 0 ? 'increased' : 'decreased';
    const percent = (Math.abs(changeRatio) * 100).toFixed(1);
    console.warn(
      `Alert: ${eventName} ${direction} by ${percent}% ` +
      `(${yesterdayCount} today vs ${twoDaysAgoCount} yesterday)`
    );
  }
};

await monitorEventFrequency('Payment_Processed', 0.2);
await monitorEventFrequency('Feature_Click', 0.15);
Run this daily to catch frequency anomalies and feed them into your incident response system.
Tip: Store daily snapshots of frequency in your own database. Over time, you'll build a baseline and can set smarter, context-aware thresholds for alerts.

Common Pitfalls

  • Inconsistent event names break frequency analysis. If you log payment_processed one week and Payment_Processed the next, Amplitude treats them as separate events and your frequency chart looks broken.
  • Missing context in events. Logging Feature_Click without including which feature, which user segment, or which page makes it impossible to diagnose frequency changes—you see a number, but can't isolate the cause.
  • Relying only on Amplitude dashboards for production alerts. Dashboards are for human monitoring. Use the REST API or Slack integration to trigger automated actions when frequency breaches thresholds.
  • Ignoring data retention limits. Amplitude keeps event-level data for 30 days; after that, only aggregated metrics remain. Set up exports to a data warehouse if you need 6-month or year-over-year frequency trends.

Wrapping Up

Monitoring event frequency in Amplitude boils down to three steps: log events consistently with the SDK, create dashboard charts to spot visual anomalies, and use the REST API for automated checks. If you want to track this automatically across tools, Product Analyst can help.

Track these metrics automatically

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

Try Product Analyst — Free