There are several ways to control which sessions you record:
Programmatically start and stop recordings
- Ensure your domain is added to the authorized domains list.
- Set
disable_session_recording: true
in your config.
posthog.init('<ph_project_api_key>', {api_host: 'https://us.i.posthog.com',disable_session_recording: true,// ... other options})
- Manually start recording by calling
posthog.startSessionRecording()
. Similarly, you can stop the recording at any point by callingposthog.stopSessionRecording()
.
With feature flags
You can select a feature flag to control whether to record sessions or not. Recordings will only be collected for users when the flag is enabled for them.
- Create a boolean flag that determines whether to record sessions or not.
- Go to the replay ingestion settings page.
- Link your newly created flag in the Enable recordings using feature flag.
Sampling
Sampling enables you to record a percentage of all sessions. To set a sampling rate, go to the replay ingestion settings page.
Our recommendation is to start with capturing 100% of sessions and decrease it as needed. This helps you get a sense of how many sessions you’re recording and how much data you’re collecting.
Note: Sampling reduces the number of sessions you record, but it doesn’t let you control which sessions are recorded.
Overriding sampling
You can begin a recording regardless of sampling by calling posthog.startSessionRecording({sampling: true})
Minimum duration
In your replay ingestion settings, you can set a minimum duration for sessions to be recorded.
This is useful if you want to exclude sessions that are too short to be useful. For example, you might want to exclude sessions that are less than 2 seconds long to avoid recording sessions where users quickly bounce off your site.
Limitations
The minimum duration is set in seconds. Whenever a new session starts, the browser records the start time. If the minimum duration has passed since the start time, the session data is sent. If it hasn't, the session continues to be buffered in-memory.
This means that if you set a high minimum duration and your user visits multiple pages each for a short time, the browser risks dropping the buffered data. The result is that the session is still recorded, but you miss the beginning.
If you find you are missing the beginning of sessions, reduce the minimum duration to fix this.
Billing Limits
You can set a billing limi. We'll stop ingesting recordings when you reach your limit.