Custom properties
Contents
Custom properties in LLM analytics enable you to add metadata to your AI generations, making it easier to filter, analyze, and understand your LLM usage patterns.
This guide shows you how to set custom properties using PostHog's LLM analytics SDKs and leverage them for better observability. For specific integration patterns, see our guides on linking to session replay and linking to error tracking.
Why use custom properties?
Custom properties help you:
- Filter traces by specific criteria (e.g., subscription tier, feature flags, account settings)
- Track prompt versions to measure improvements over time
- Link backend LLM events to session replays and error tracking
- Group related generations by custom business logic (e.g, sessions, conversations, tenants )
- Monitor costs by user segments or features
Setting custom properties
You can add custom properties to any LLM generation using the posthogProperties
parameter (JavaScript) or posthog_properties
parameter (Python). These properties will appear in the $ai_generation
event alongside the automatically captured metrics in your PostHog dashboard.
Basic example
Common use cases
1. Subscription tier tracking
Track LLM usage by subscription tier or payment plan to monitor costs and usage patterns:
2. Prompt versioning
Track different versions of your prompts to measure improvements:
3. Custom generation names
Set meaningful names for your LLM generations to improve trace readability:
The $ai_span_name
property will appear as the primary label in your trace visualization, making it easier to identify specific operations.
Filtering in the dashboard
Once you've set custom properties, they appear in the PostHog LLM analytics dashboard where you can:
- Filter generations by any custom property
- Create insights based on custom properties
- Build dashboards segmented by your custom fields
For example, after setting a conversation_id
property, you can:
- Filter the generations table to show only events from a specific conversation
- Create a funnel to track conversation completion rates
- Build a dashboard showing average cost per conversation by user subscription tier
Your custom properties will appear in the event details panel alongside the automatically captured properties like model, tokens, and latency.