PostHogConfig
Properties
Name | Type |
---|---|
__add_tracing_headers | string[] |
PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION A list of hostnames for which to inject PostHog tracing headers to all requests (X-POSTHOG-DISTINCT-ID, X-POSTHOG-SESSION-ID, X-POSTHOG-WINDOW-ID) | |
__preview_flags_v2 | boolean |
PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION Whether to use the new /flags/ endpoint | |
__preview_remote_config | boolean |
PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION Enables the new RemoteConfig approach to loading config instead of /flags?v=2&config=true | |
_onCapture | (eventName: string, eventData: CaptureResult) => void |
advanced_disable_decide | boolean |
advanced_disable_feature_flags_on_first_load | boolean |
Stops from firing feature flag requests on first page load. Only requests feature flags when user identity or properties are updated, or you manually request for flags to be loaded. false | |
advanced_disable_feature_flags | boolean |
Will keep /flags running, but without evaluating any feature flags. Useful for when you need to load the config data associated with the flags endpoint (e.g. /flags?v=2&config=true) without evaluating any feature flags. Most folks use this to save money on feature flag evaluation (by bootstrapping feature flags on the server side). false | |
advanced_disable_flags | boolean |
One of the very first things the PostHog library does when init() is called is make a request to the /flags endpoint on PostHog's backend. This endpoint contains information on how to run the PostHog library so events are properly received in the backend, and it also contains feature flag evaluation information for the current user. This endpoint is required to run most features of this library. However, if you're not using any of the described features, you may wish to turn off the call completely to avoid an extra request and reduce resource usage on both the client and the server. false | |
advanced_disable_toolbar_metrics | boolean |
Determines whether PostHog should disable toolbar metrics. This is our internal instrumentation for our toolbar in your website. false | |
advanced_enable_surveys | boolean |
When this is enabled, surveys will always be initialized, regardless of the /flags response or remote config settings. This is useful if you want to use surveys but disable all other flag-dependent functionality. Used internally for displaying external surveys without making a /flags request. false | |
advanced_only_evaluate_survey_feature_flags | boolean |
Determines whether PostHog should only evaluate feature flags for surveys. Useful for when you want to use this library to evaluate feature flags for surveys only but you have additional feature flags that you evaluate on the server side. false | |
api_host | string |
URL of your PostHog instance. 'https://us.i.posthog.com' | |
api_method | string |
api_transport | 'XHR' | 'fetch' |
The transport method to use for API requests. 'fetch' | |
autocapture | boolean | AutocaptureConfig |
Determines whether PostHog should autocapture events. This setting does not affect capturing pageview events (see | |
before_send | BeforeSendFn | BeforeSendFn[] |
This function or array of functions - if provided - are called immediately before sending data to the server. It allows you to edit data before it is sent, or choose not to send it all. if provided as an array the functions are called in the order they are provided any one function returning null means the event will not be sent | |
bootstrap | BootstrapConfig |
An object containing the | |
capture_dead_clicks | boolean | DeadClicksAutoCaptureConfig |
Determines whether to capture dead clicks. | |
capture_exceptions | boolean | ExceptionAutoCaptureConfig |
Determines whether to capture exceptions. | |
capture_heatmaps | boolean | HeatmapConfig |
Determines whether to capture heatmaps. | |
capture_pageleave | boolean | 'if_capture_pageview' |
Determines whether PostHog should capture pageleave events. If set to | |
capture_pageview | boolean | 'history_change' |
Determines whether PostHog should capture pageview events automatically. Can be: - | |
capture_performance | boolean | PerformanceCaptureConfig |
Determines whether to capture performance metrics. These include Network Timing and Web Vitals.
When | |
consent_persistence_name | string | null |
Determines the key for the cookie / local storage used to store the information about whether users are opted in/out of capturing. When | |
cookie_expiration | number |
Determines the number of days to store cookies for. 365 | |
cookie_name | string |
cookieless_mode | 'always' | 'on_reject' |
Enables cookieless mode. In this mode, PostHog will not set any cookies, or use session or local storage. User identity is handled by generating a privacy-preserving hash on PostHog's servers. - 'always' - enable cookieless mode immediately on startup, use this if you do not intend to show a cookie banner - 'on_reject' - enable cookieless mode only if the user rejects cookies, use this if you want to show a cookie banner. If the user accepts cookies, cookieless mode will not be used, and PostHog will use cookies and local storage as usual. Note that you MUST enable cookieless mode in your PostHog project's settings, otherwise all your cookieless events will be ignored. We plan to remove this requirement in the future. | |
cross_subdomain_cookie | boolean |
Determines if cookie should be set on the top level domain (example.com). If PostHog-js is loaded on a subdomain (test.example.com), and | |
custom_blocked_useragents | string[] |
Used to extend the list of user agents that are blocked by default. | |
custom_campaign_params | string[] |
Used to extend the list of campaign parameters that are saved by default. | |
custom_personal_data_properties | string[] |
Custom list of personal data properties to mask.
E.g. if you added | |
debug | boolean |
Determines whether PostHog should be in debug mode. You can enable this to get more detailed logging.
You can also enable this on your website by appending | |
defaults | ConfigDefaults |
Configuration defaults for breaking changes. When set to a specific date, enables new default behaviors that were introduced on that date.
| |
disable_compression | boolean |
Determines whether to disable compression when sending events to the server. WARNING: Should only be used for testing. Could negatively impact performance. false | |
disable_cookie | boolean |
disable_external_dependency_loading | boolean |
Determines whether PostHog should disable any external dependency loading. This will prevent PostHog from requesting any external scripts such as those needed for Session Replay, Surveys or Site Apps. false | |
disable_persistence | boolean |
Determines whether PostHog should disable persistence. If set to | |
disable_scroll_properties | boolean |
Determines whether to disable scroll properties. These allow you to keep track of how far down someone scrolled in your website. false | |
disable_session_recording | boolean |
Determines whether PostHog should disable session recording. false | |
disable_surveys_automatic_display | boolean |
Determines whether PostHog should disable automatic display of surveys. If this is true, popup or widget surveys will not be shown when display conditions are met. false | |
disable_surveys | boolean |
Determines whether PostHog should disable all surveys functionality. false | |
disable_web_experiments | boolean |
Determines whether PostHog should disable web experiments.
Currently disabled while we're in BETA. It will be toggled to | |
enable_heatmaps | boolean |
enable_recording_console_log | boolean |
Determines whether PostHog should enable recording console logs. When undefined, it falls back to the remote config setting. undefined | |
error_tracking | ErrorTrackingOptions |
Determines the error tracking options. | |
feature_flag_request_timeout_ms | number |
Sets timeout for fetching feature flags 3000 | |
fetch_options | {
cache?: RequestInit['cache'];
next_options?: NextOptions;
} |
Used when sending data via | |
get_device_id | (uuid: string) => string |
Function to get the device ID. This doesn't usually need to be set, but can be useful if you want to use a custom device ID. | |
inapp_link_new_window | boolean |
inapp_protocol | string |
integrations | Record<ExternalIntegrationKind, boolean> |
Used to set-up external integrations with PostHog data - such as session replays, distinct id, etc. | |
ip | boolean |
loaded | (posthog_instance: PostHog) => void |
A function to be called once the PostHog scripts have loaded successfully. | |
mask_all_element_attributes | boolean |
Prevent autocapture from capturing any attribute names on elements. false | |
mask_all_text | boolean |
Prevent autocapture from capturing | |
mask_personal_data_properties | boolean |
Mask personal data properties from the current URL. This will mask personal data properties such as advertising IDs (gclid, fbclid, etc.), and you can also add custom properties to mask with | |
name | string |
The name this instance will be identified by. You don't need to set this most of the time, but can be useful if you have several Posthog instances running at the same time. 'posthog' | |
on_request_error | (error: RequestResponse) => void |
A function that is called when a request to the PostHog API fails. | |
on_xhr_error | (failedRequest: XMLHttpRequest) => void |
opt_in_site_apps | boolean |
Determines if users should be opted in to site apps. false | |
opt_out_capturing_by_default | boolean |
Determines if users should be opted out of PostHog tracking by default, requiring additional logic to opt them into capturing by calling | |
opt_out_capturing_cookie_prefix | string | null |
opt_out_capturing_persistence_type | 'localStorage' | 'cookie' |
Determines where we'll save the information about whether users are opted out of capturing. 'localStorage' | |
opt_out_persistence_by_default | boolean |
Determines if users should be opted out of browser data storage by this PostHog instance by default, requiring additional logic to opt them into capturing by calling | |
opt_out_useragent_filter | boolean |
Determines if users should be opted out of user agent filtering such as googlebot or other bots. If this is set to | |
persistence_name | string |
The name for the super properties persistent store '' | |
persistence | 'localStorage' | 'cookie' | 'memory' | 'localStorage+cookie' | 'sessionStorage' |
Determines how PostHog stores information about the user. See persistence for details. 'localStorage+cookie' | |
person_profiles | 'always' | 'never' | 'identified_only' |
You can control whether events from PostHog-js have person processing enabled with the | |
prepare_external_dependency_script | (script: HTMLScriptElement) => HTMLScriptElement | null |
A function to be called when a script is being loaded. This can be used to modify the script before it is loaded. This is useful for adding a nonce to the script, for example. | |
prepare_external_dependency_stylesheet | (stylesheet: HTMLStyleElement) => HTMLStyleElement | null |
A function to be called when a stylesheet is being loaded. This can be used to modify the stylesheet before it is loaded. This is useful for adding a nonce to the stylesheet, for example. | |
process_person | 'always' | 'never' | 'identified_only' |
properties_string_max_length | number |
Determines the maximum length of the properties string that can be sent with capture calls. 65535 | |
property_blacklist | string[] |
property_denylist | string[] |
A list of properties that should never be sent with capture calls. [] | |
rageclick | boolean |
Determines whether PostHog should capture rage clicks. true | |
rate_limiting | {
events_per_second?: number;
events_burst_limit?: number;
} |
Client side rate limiting | |
request_batching | boolean |
Determines whether PostHog should batch requests to the PostHog API. true | |
request_headers | {
[header_name: string]: string;
} |
A list of headers that should be sent with requests to the PostHog API. | |
request_queue_config | RequestQueueConfig |
Used to change the behavior of the request queue. This is an advanced feature and should be used with caution. | |
respect_dnt | boolean |
Determines whether PostHog should respect the Do Not Track header when computing consent in | |
sanitize_properties | ((properties: Properties, event_name: string) => Properties) | null |
save_campaign_params | boolean |
Determines whether PostHog should save marketing parameters. These are | |
save_referrer | boolean |
Determines whether PostHog should save referrer information. true | |
scroll_root_selector | string | string[] |
Let the pageview scroll stats use a custom css selector for the root element, e.g. | |
secure_cookie | boolean |
Determines whether PostHog should use secure cookies. If this is | |
segment | SegmentAnalytics |
The segment analytics object. | |
session_idle_timeout_seconds | number |
Determines the session idle timeout in seconds. Any new event that's happened after this timeout will create a new session. 30 * 60 -- 30 minutes | |
session_recording | SessionRecordingOptions |
Determines the session recording options. | |
store_google | boolean |
surveys_request_timeout_ms | number |
Sets timeout for fetching surveys 10000 | |
token | string |
The token for your PostHog project. It should NOT be provided manually in the config, but rather passed as the first parameter to | |
ui_host | string | null |
If using a reverse proxy for | |
upgrade | boolean |
Determines whether PostHog should upgrade old cookies. If set to | |
verbose | boolean |
xhr_headers | {
[header_name: string]: string;
} |