6 min read

How to Set Up Alerts for Page Views in PostHog

Manually checking your page view trends is a time sink. PostHog lets you set up automated alerts that fire when page views exceed or fall below a threshold you define. This guide walks you through creating a page view insight and configuring alerts around it.

Create a Page View Insight

First, you need an insight that tracks page views over time. PostHog captures $pageview events automatically, but you can also manually track them.

Navigate to Insights

In the PostHog sidebar, click Insights. You'll see your existing insights and an option to create a new one.

Create a Trends insight

Click New insight (or the plus button), then select Trends. This view lets you track metrics over time, which is perfect for monitoring page view volume.

Filter for Page View Events

In the Events section, search for and select $pageview. This is the automatic event PostHog captures every time someone loads a page. If you're tracking custom page view events instead, select those.

javascript
// PostHog automatically captures $pageview events when initialized
// Optional: manually capture page view events
posthog.capture('$pageview', {
  '$current_url': window.location.href,
  'page_title': document.title
});
PostHog captures page views automatically; manual capture is optional for custom tracking

Configure the Chart

Choose Total Count as the metric (or Unique Users if you want to alert on unique visitors). Set the time interval to Day or Hour depending on how volatile your traffic is. PostHog displays the trend immediately.

Tip: Use the Breakdown by dropdown to segment page views by property (e.g., by page path, device, or user property) so you can alert on specific pages instead of total traffic.

Configure the Alert Threshold

Once your insight displays the data you want to monitor, set up the alert condition.

Click the Alert Icon

At the top right of your insight, look for the bell icon. Click it to open the alert configuration panel. If the icon isn't visible, make sure you've saved the insight first.

Set the Threshold Condition

Choose whether you want to alert when the metric goes above or below a certain value. Enter your threshold (e.g., 5000 page views per day). You can also set a minimum observation period to avoid false positives.

javascript
// Create an alert via PostHog API
const alertConfig = {
  name: 'Daily Page Views Alert',
  insight: insightId,
  condition: {
    comparison_operator: 'gt', // 'gt' = greater than, 'lt' = less than
    threshold: 5000
  }
};

await fetch('https://your-instance.posthog.com/api/projects/PROJECT_ID/alerting_rules/', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${personalApiKey}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(alertConfig)
});
PostHog also supports API-based alert configuration for automation

Choose Notification Channels

Select where you want to be notified: Slack, Email, or Webhook. For Slack, authorize PostHog to post to your workspace and choose a channel. For email, enter your address or team alias.

Watch out: If you set a threshold too close to your normal traffic range, you'll get alert fatigue. Look at your trend chart's historical data and set the threshold 20–30% above or below your baseline.

Monitor and Refine

After your alert is active, periodically review its performance and adjust thresholds based on actual traffic patterns.

Check Alert History

In the Alerts section (accessible from the sidebar or your insight), review the alert log. You'll see when alerts fired, what triggered them, and the actual metric values. This helps you understand whether your threshold is calibrated correctly.

Adjust Thresholds Based on Seasonality

If you notice false positives or missed alerts, edit the threshold. PostHog lets you update alert conditions without recreating the insight. Consider seasonal traffic patterns (weekends might have lower page views) and adjust your threshold per day-of-week if needed.

javascript
// Update an existing alert
const alertId = 'abc123';
const updatedAlert = {
  condition: {
    comparison_operator: 'gt',
    threshold: 7000 // increased threshold
  }
};

await fetch(`https://your-instance.posthog.com/api/projects/PROJECT_ID/alerting_rules/${alertId}/`, {
  method: 'PATCH',
  headers: {
    'Authorization': `Bearer ${personalApiKey}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(updatedAlert)
});
Update alert thresholds via API without recreating the insight
Tip: Combine page view alerts with Slack workflow automation to trigger follow-up actions (e.g., notify engineering if page views drop below a threshold for 2 consecutive hours).

Common Pitfalls

  • Setting thresholds too aggressively — if your alert fires for every minor fluctuation, your team will ignore it. Leave headroom for natural variance.
  • Not considering timezone differences — PostHog times alerts in UTC by default, which can cause unexpected firing times if your team is distributed.
  • Forgetting to test the notification channel — create the alert and manually trigger it by adjusting the threshold temporarily to confirm Slack or email actually receives the notification.
  • Alerting on total page views without segmentation — an overall spike might hide a drop in a critical page. Use breakdowns to alert on specific paths.

Wrapping Up

You now have a reliable system to catch traffic anomalies without staring at dashboards. Page view alerts are just the start — you can set similar thresholds on conversion funnels, user signup trends, or any metric in PostHog. If you want to track and alert on this automatically across your entire toolchain, Product Analyst can help.

Track these metrics automatically

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

Try Product Analyst — Free