5 min read

How to Set Up Alerts for Conversion Rate in PostHog

Conversion rate is the metric that usually matters most, so the last thing you want is to miss a sudden drop. PostHog lets you build a funnel, track it, and set up alerts that fire when conversion rate dips below your threshold. You'll catch problems before they become expensive.

Track Your Conversion Events

PostHog needs to know what counts as a conversion. You'll capture two events: the starting action and the completion action.

Initialize PostHog and capture the starting event

Load the PostHog SDK and fire an event when the conversion funnel begins (e.g., user lands on pricing). Use posthog.capture() to send the event with relevant properties.

javascript
import posthog from 'posthog-js'

posthog.init('phc_your_api_key', {
  api_host: 'https://app.posthog.com',
})

// Fire when conversion funnel starts
posthog.capture('pricing_viewed', {
  plan_interest: 'pro',
  source: 'search'
})
Initialize PostHog and track the starting event.

Capture the conversion completion event

When the user completes the desired action (e.g., subscribes), fire a second event. Include properties like plan type and revenue so you can slice by segment later.

javascript
// Fire when user completes conversion
posthog.capture('purchase_completed', {
  plan: 'pro',
  amount: 99,
  billing_cycle: 'monthly'
})
Capture the conversion event when the user completes the action.
Watch out: Event tracking must be reliable or your conversion rate will be wrong. Test both events fire consistently using PostHog's Network inspector before setting up alerts.

Create a Funnel and Alert

Build the funnel in PostHog's UI, then set a threshold alert that notifies you when conversion rate drops.

Create the funnel in PostHog

In PostHog, go to Insights and click New insight > Funnel. Add pricing_viewed as step 1, then purchase_completed as step 2. PostHog calculates the conversion rate automatically.

Set the alert threshold

In your funnel view, click the Alerts button. Choose Create alert and set the threshold (e.g., alert if conversion rate drops below 5%). Select your notification channel: Email, Slack, or webhook.

javascript
// Create alert programmatically via PostHog's subscriptions API
const alertConfig = {
  subscribed_type: 'insight_alert',
  threshold: 5, // Alert if conversion rate drops below 5%
  comparison: 'less_than',
  insight_id: 'your-funnel-id', // Get this from the funnel URL
}

const response = await fetch(
  'https://app.posthog.com/api/projects/YOUR_PROJECT_ID/subscriptions/',
  {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${POSTHOG_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(alertConfig),
  }
)

const alert = await response.json()
console.log('Alert created with ID:', alert.id)
Create an alert programmatically using PostHog's subscriptions API.

Test the alert

Temporarily set the threshold to 99% to trigger the alert immediately. Verify you receive the notification, then adjust back to your actual threshold (e.g., 5%). This confirms your notification channel works.

Tip: Set multiple alerts at different thresholds—a 50% drop alert catches catastrophic failures, a 10% drop alert catches slower degradation. Use Slack for fast triage, email for formal incident logs.

Monitor and Refine

Once your alert is live, keep it tuned to your business.

Review alert history

In the funnel view, check the Alert history tab. See which thresholds fire most often. If you're getting alerts weekly, either raise the threshold or investigate why conversion rate is volatile.

Compare periods to avoid false positives

PostHog can alert on week-over-week or day-over-day changes instead of fixed thresholds. This helps avoid false alarms from seasonal shifts. In the alert settings, choose Comparison type > Compared to previous period.

javascript
// Update alert to compare to previous period
const updateAlertPayload = {
  comparison: 'relative',
  comparison_period: 'previous_week', // Compare this week to last week
  threshold: 20, // Alert if conversion rate is 20% lower than last week
}

const updateResponse = await fetch(
  `https://app.posthog.com/api/projects/YOUR_PROJECT_ID/subscriptions/ALERT_ID/`,
  {
    method: 'PATCH',
    headers: {
      'Authorization': `Bearer ${POSTHOG_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(updateAlertPayload),
  }
)

const updatedAlert = await updateResponse.json()
console.log('Alert updated:', updatedAlert)
Update an alert to compare against the previous period instead of a fixed threshold.
Tip: A high-signal alert beats a high-volume alert. If your alert fires so often that you ignore it, your threshold is wrong. Adjust until it only fires on changes that actually matter.

Common Pitfalls

  • Event capture inconsistencies tank your conversion rate accuracy. If pricing_viewed fires but purchase_completed is sporadic, you'll get false low conversion rates.
  • Fixed thresholds can create noise in seasonal businesses. Weekends, holidays, and new feature launches naturally depress conversion. Use week-over-week alerts instead.
  • PostHog funnels require both events from the same user in the same session (or at least the same user ID). Cross-domain funnels or multi-session flows may not calculate correctly.
  • Too many alert channels (Slack + email + webhook) lead to alert fatigue. Pick one primary channel for triage, one secondary for escalation.

Wrapping Up

You now have real-time visibility into conversion rate and will catch drops before they compound. Adjust your threshold based on what fires repeatedly. If you want to track this automatically across multiple tools and products, Product Analyst can help.

Track these metrics automatically

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

Try Product Analyst — Free