How to control which sessions you record

Last updated:

|Edit this page

If you want control over which sessions to record:

  1. Set disable_session_recording: true in your config.

  2. Manually start recording by calling posthog.startSessionRecording(). Similarly, you can stop the recording at any point by calling posthog.stopSessionRecording().

You can then achieve even finer control by combining the above methods with feature flags. This enables you to control session recordings based on user or group properties. You can also use feature flags to capture a percentage of all sessions.

For example:

Web
posthog.init('<ph_project_api_key>', {
api_host: '<ph_instance_address>',
disable_session_recording: true,
// ... other options
})
posthog.onFeatureFlags(function () {
if (posthog.isFeatureEnabled('your-feature-flag')) {
posthog.startSessionRecording()
}
})

For more examples of controlling which sessions you record, see our tutorial on how to only record the sessions you want.

Questions?

Was this page useful?

Next article

Console logs recording

PostHog can capture console logs from your application. This is useful for debugging and providing extra context on what is happening in your user's browser environment. As console logs can contain sensitive information, we do not capture these logs automatically. You can enable this feature globally from your project settings or client-side by setting enable_recording_console_log: true in our JavaScript web library config . Important: Console logs are recorded if either the project…

Read next article