If you want control over which sessions to record:
Set
disable_session_recording: true
in your config.Manually start recording by calling
posthog.startSessionRecording()
. Similarly, you can stop the recording at any point by callingposthog.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:
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.