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

Troubleshooting and FAQs

Having trouble with recordings? Below are some tips for getting past some common issues The most common solution is... Update posthog-js We're always making improvements to the recordings feature, so you'll want to make sure that you're running the latest version of posthog-js on your website. To check the version that you're using, you can run the following in your browser console: Recordings are not being captured There are a few common reasons that you may not see recordings appear in your…

Read next article