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.
// 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
});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.
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.
// 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)
});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.
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.
// 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)
});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.