Skip to main content

Insight

Create and manage analytics insights and queries
2 min read

The Insight resource allows you to create and manage analytics insights for tracking events, funnels, retention, and other metrics in PostHog.

Example Usage#

Signup Tracking#

Retention Analysis#

Insight on Dashboard#

Insight with Tags#

Funnel Analysis#

Resource Properties#

Required Arguments#

  • queryJson (string): Raw JSON serialized query payload accepted by PostHog (e.g., InsightVizNode with a TrendsQuery)

Optional Arguments#

  • name (string): Insight name
  • description (string): Insight description
  • dashboardIds (number[]): List of dashboard IDs to add the insight to
  • createInFolder (string): Folder where the insight is created
  • tags (string[]): List of tags to apply to the insight
  • deleted (boolean): Whether the insight is deleted (soft delete)
  • derivedName (string): Insight derived name (auto-generated by PostHog when name is not set)

Attributes#

  • insightId: Numeric insight ID
  • name: Insight name
  • derivedName: Auto-generated insight name

Query Types#

PostHog supports several query types:

TrendsQuery#

Track event volumes over time:

FunnelsQuery#

Analyze conversion funnels:

RetentionQuery#

Measure user retention:

Best Practices#

1. Use Descriptive Names#

2. Add to Relevant Dashboards#

3. Use Tags for Organization#

Common Use Cases#

User Engagement Tracking#

Feature Adoption#

Conversion Tracking#

Troubleshooting#

Invalid Query JSON#

Issue: Error creating insight with invalid query

Solution:

  • Ensure queryJson is a valid JSON string
  • Use JSON.stringify() to convert objects to JSON strings
  • Validate query structure matches PostHog's query schema

Insight Not Showing Data#

Issue: Insight created but shows no data

Solution:

  • Verify the event name exists in PostHog
  • Check the date range includes data
  • Confirm events are being captured

Dashboard Assignment Fails#

Issue: Cannot add insight to dashboard

Solution:

  • Use numeric dashboard IDs (from PostHog)
  • Ensure dashboard exists before creating insight
  • Verify you have access to the dashboard

Additional Resources#