You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: contents/docs/data/sessions.mdx
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ A session can span multiple tabs and windows, but only on the same browser and d
32
32
33
33
Activity is defined as any event sent from the client including autocapture events and replay activity like mouse movement. The inactivity period can be configured using the `session_idle_timeout_seconds`[configuration option](/docs/libraries/js/config).
34
34
35
-
> **Note:** If you are [migrating data](/docs/migrate) or [using a CDP](/docs/advanced/cdp), you may need to manually set the `$session_id` property if you want to query sessions or connect them to session replays.
35
+
> **Note:** If you are [migrating data](/docs/migrate) or [using a CDP](/docs/advanced/cdp), you may need to manually set the `$session_id` property if you want to query sessions or connect them to session replays.
36
36
> If you are using the JavaScript Web SDK alongside your CDP, you can get this value by calling `posthog.get_session_id()`.
37
37
38
38
## Session properties
@@ -86,9 +86,9 @@ The easiest way to analyze a session is to view a [session replay](/docs/session
86
86
[Web analytics](/docs/web-analytics) also gives you an easily accessible overview. The top section contains sessions, session duration, and bounce rate, while further down provides more details on entry paths, exit paths, top channels, device types, and more.
@@ -103,18 +103,18 @@ This provides the count of unique sessions where the specified event occurred. T
103
103
To do this, select **Unique sessions** from the aggregation dropdown.
104
104
105
105
<ProductScreenshot
106
-
imageLight={uniqueSessionLight}
106
+
imageLight={uniqueSessionLight}
107
107
imageDark={uniqueSessionDark}
108
-
alt="Session counts"
108
+
alt="Session counts"
109
109
classes="rounded"
110
110
/>
111
111
112
112
This can then be used in a formula to understand things like the average number of sessions per user or the average number of events per session.
113
113
114
114
<ProductScreenshot
115
-
imageLight={sessionFormulaLight}
115
+
imageLight={sessionFormulaLight}
116
116
imageDark={sessionFormulaDark}
117
-
alt="Session formula"
117
+
alt="Session formula"
118
118
classes="rounded"
119
119
/>
120
120
@@ -123,9 +123,9 @@ This can then be used in a formula to understand things like the average number
123
123
You can use any of the session properties to filter your data. For example, to remove sessions that are shorter than 10 seconds, you can filter for sessions where duration is greater than 10 seconds.
@@ -134,9 +134,9 @@ You can use any of the session properties to filter your data. For example, to r
134
134
You can plot session properties over time like you would with an event count. To do this, select one of the property aggregators (e.g. median, 90th percentile, etc.) and then select the session property to plot. For example, to plot the median session duration, select **Property value median** and then select **Session duration** as the property.
135
135
136
136
<ProductScreenshot
137
-
imageLight={medianDurationLight}
137
+
imageLight={medianDurationLight}
138
138
imageDark={medianDurationDark}
139
-
alt="Session median duration"
139
+
alt="Session median duration"
140
140
classes="rounded"
141
141
/>
142
142
@@ -149,7 +149,7 @@ This is useful for understanding entry URLs or UTMs. For example, to break down
@@ -163,11 +163,11 @@ If the events are logically part of the same session, e.g. a user starts a purch
163
163
164
164
### Automatically sending session IDs
165
165
166
-
If you enable tracing headers within the JavaScript SDK, the session ID will be sent on every request.
166
+
If you enable tracing headers within the JavaScript SDK, the session ID will be sent on every request. You can enable tracing headers by adding the `__add_tracing_headers` option to your `posthog.init` call:
Copy file name to clipboardExpand all lines: contents/docs/libraries/python/_snippets/contexts.mdx
+11-2Lines changed: 11 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -94,7 +94,7 @@ with new_context():
94
94
95
95
It's recommended to pass the currently active distinct ID from the frontend to the backend, using the `X-POSTHOG-DISTINCT-ID` header. If you're using our Django middleware, this is extracted and associated with the request handler context automatically.
96
96
97
-
You can read more about identifying users in the [user identification documentation](/docs/product-analytics/identify).
97
+
You can read more about identifying users in the [user identification documentation](/docs/product-analytics/identify).
98
98
99
99
### Contexts and sessions
100
100
@@ -108,7 +108,16 @@ with new_context():
108
108
109
109
<CalloutBoxicon="IconInfo"title="Using PostHog on your frontend too?">
110
110
111
-
If you're using the PostHog JavaScript Web SDK on your frontend, it generates a session ID for you and you can retrieve it by calling `posthog.get_session_id()`. You then need to pass that session ID to your backend by setting the `X-POSTHOG-SESSION-ID` header on each fetch request. Alternatively, you can enable '__add_tracing_headers' in your config and the header is set automatically.
111
+
If you're using the PostHog JavaScript Web SDK on your frontend, it generates a session ID for you.
112
+
You can pass it to your backend by adding your backend domain to `__add_tracing_headers` in your config. This will automatically add tracing headers to your requests.
Alternatively, you can retrieve it on the frontend by calling `posthog.get_session_id()`. You then need to pass that session ID to your backend by setting the `X-POSTHOG-SESSION-ID` header on each fetch request.
112
121
113
122
You need to extract the header in your request handler (if you're using our Django middleware integration, this happens automatically).
Copy file name to clipboardExpand all lines: contents/docs/libraries/python/_snippets/django-context-middleware.mdx
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,8 +23,10 @@ All events captured during the request (including exceptions) will include these
23
23
24
24
If you are using PostHog on your frontend, the JavaScript Web SDK will add the session and distinct ID headers automatically if you enable tracing headers.
0 commit comments