6 min read

How to Calculate Event Volume in PostHog

Event volume directly affects your PostHog bill and tells you how active your users are. If you're unsure whether you're tracking too many events or need to understand your ingestion rate, you need a quick way to see total events over a period.

Calculate Event Volume Through the PostHog UI

The simplest approach is to use PostHog's built-in insights and events tools.

Open the Events table in PostHog

Navigate to Data Management > Events or go directly to Insights. You'll see a table listing all events from your project with timestamps and event names.

javascript
// No code needed for UI — just navigate to Data Management > Events
// Filter by date range to see volume over time
Use the Events table to see raw event counts

Use the Events Insight to aggregate volume by time

Create a new Insight and select Events as the chart type. Choose the event you want to measure (or leave it blank for all events), then group by Time (daily, hourly, weekly). This shows your ingestion rate visually.

javascript
// PostHog Insight query (conceptual)
// Chart type: Events
// Series: All events (or specific event name)
// Group by: Day / Hour / Week
// Filter by date range as needed
Grouping by time in Insights shows your ingestion trend

Add filters to narrow volume calculation

Use the Filters panel to exclude internal traffic, test events, or specific event names. For example, filter by event != '$pageview' to exclude pageview clutter, or by team to isolate production events.

javascript
// Filter example in PostHog Insights
// event != '$pageview'
// properties.environment = 'production'
// timestamp >= 2024-01-01
Apply filters to focus on meaningful event volume
Tip: Save your Insight to a dashboard for quick reference. You can return to it anytime to check current event volume without rebuilding the query.

Query Event Volume Programmatically via API

For automated monitoring or integration into your dashboards, use PostHog's API to fetch event counts.

Authenticate and set up your API request

You'll need your PostHog API Key (find it in Project Settings > API Keys). Use it to authenticate HTTP requests to the PostHog API.

javascript
const posthogApiKey = process.env.POSTHOG_API_KEY;
const projectId = 'your-project-id';
const posthogUrl = 'https://us.posthog.com';

const headers = {
  'Authorization': `Bearer ${posthogApiKey}`,
  'Content-Type': 'application/json'
};
Set up authentication headers for PostHog API

Query the /events endpoint for volume data

Call the Events API endpoint to retrieve a count of events within a date range. You can filter by event name, properties, and timestamp.

javascript
const fetch = require('node-fetch');

const getEventVolume = async (startDate, endDate) => {
  const params = new URLSearchParams({
    'select': 'count()',
    'where': `timestamp >= '${startDate}' AND timestamp <= '${endDate}'`
  });

  const url = `${posthogUrl}/api/projects/${projectId}/events/?${params}`;
  const response = await fetch(url, { headers });
  const data = await response.json();
  
  return data.count;
};

getEventVolume('2024-01-01', '2024-01-31').then(count => {
  console.log(`Total events: ${count}`);
});
Query the API to get event volume across a date range

Break down volume by event type

Instead of total volume, group by event to see which event types are driving your ingestion. This helps identify which features or tracking calls consume the most volume.

javascript
const getEventVolumeByType = async (startDate, endDate) => {
  const params = new URLSearchParams({
    'select': 'event, count() as volume',
    'where': `timestamp >= '${startDate}' AND timestamp <= '${endDate}'`,
    'group_by': 'event'
  });

  const url = `${posthogUrl}/api/projects/${projectId}/events/?${params}`;
  const response = await fetch(url, { headers });
  const data = await response.json();
  
  return data;
};

getEventVolumeByType('2024-01-01', '2024-01-31').then(events => {
  events.forEach(e => console.log(`${e.event}: ${e.volume}`));
});
Group by event name to see volume per event type
Watch out: The API has rate limits and pagination. If your project has millions of events, break your queries into smaller date ranges or use the limit parameter to paginate results.

Monitor Event Volume Over Time

Set up continuous monitoring to track ingestion trends and catch unexpected spikes.

Create a recurring check for volume anomalies

Use the API to compare current period volume against a baseline (e.g., previous week or month). If the current week's volume is significantly higher, alert yourself or your team.

javascript
const compareEventVolume = async () => {
  const now = new Date();
  const currentWeekStart = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000);
  const previousWeekStart = new Date(now.getTime() - 14 * 24 * 60 * 60 * 1000);
  const previousWeekEnd = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000);

  const currentVolume = await getEventVolume(
    currentWeekStart.toISOString().split('T')[0],
    now.toISOString().split('T')[0]
  );
  
  const previousVolume = await getEventVolume(
    previousWeekStart.toISOString().split('T')[0],
    previousWeekEnd.toISOString().split('T')[0]
  );

  const percentChange = ((currentVolume - previousVolume) / previousVolume) * 100;
  
  if (percentChange > 20) {
    console.warn(`⚠️ Event volume up ${percentChange}% week-over-week`);
  }
};

compareEventVolume();
Compare current volume against baseline to detect spikes

Export results to a monitoring tool

Send volume metrics to your favorite monitoring tool (e.g., Datadog, Grafana, or a Google Sheet). Run this check hourly or daily to track trends.

javascript
const sendVolumeMetric = async (metric, value) => {
  const datadogUrl = 'https://api.datadoghq.com/api/v1/series';
  const datadogApiKey = process.env.DATADOG_API_KEY;

  const payload = {
    series: [{
      metric: `posthog.event_volume.${metric}`,
      points: [[Math.floor(Date.now() / 1000), value]],
      tags: ['service:product-analyst']
    }]
  };

  await fetch(datadogUrl, {
    method: 'POST',
    headers: { 'DD-API-KEY': datadogApiKey },
    body: JSON.stringify(payload)
  });
};

await sendVolumeMetric('total', currentVolume);
Send volume metrics to external monitoring systems
Tip: Combine event volume tracking with cost analysis. PostHog charges per 1M events; knowing your volume helps forecast monthly bills.

Common Pitfalls

  • Forgetting to filter out internal traffic (team members, staging environments). This inflates your volume and skews cost calculations.
  • Counting all events including PostHog's reserved events ($pageview, $identify, etc.). If you only care about custom events, exclude these explicitly.
  • Querying too broad a date range via the API without pagination. Large ranges can timeout; break into smaller chunks and sum the results.
  • Assuming event volume is constant day-to-day. Plan for peak hours and seasonal spikes when estimating PostHog usage.

Wrapping Up

You now have two paths to calculate event volume: the PostHog UI for quick checks, and the API for automation and monitoring. Event volume is critical for billing forecasting, debugging production issues, and understanding user activity. If you want to track event volume automatically across PostHog and other analytics 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