Skip to content

Commit fd40780

Browse files
Update sessionization.md
1 parent 7b03da9 commit fd40780

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

sessionization.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ Whereas, timeseries analysis, usually uses "Gaps and Islands" - if there are no
1010
|:--:|
1111
|_Figure 1._ A session, for example, can be defined by threshold time such as if the next action is in a range of time greater than `T=50`, it defines the start of a new session.
1212

13+
## Why do you nee sessionization?
14+
15+
Sessionization has many use cases: web traffic patterns, cohort analysis, attribution, etc. Sessions make it easier to group and analyze events and actions users take which helps us understand the customer journey and their interactions with your product. This allows you to optimize your marketing campaigns and user flows to increase conversion rates and bring in more business.
16+
17+
## How do you sessionize in SQL?
18+
19+
You can use the `CONDITIONAL_TRUE_EVENT` function to easily sessionize events in one line of SQL code.
20+
21+
1. First, you'll need to structure your data so there is one row per event.
22+
2. Next, you'll need to get the timestamp of the previous event for each event, partitioned by _visitor identifier_ or _username_.
23+
4. Next, compare the _previous timestamp_ to the _current timestamp_ in order to calculate how much time elapsed between the two events.
24+
5. If the time between the two events is less than _n_ minutes, these two events are in the same session. If the time between the two events was greater than _n_ minutes, consider these two events to be in separate sessions.
1325

1426
## An illustrative example
1527

0 commit comments

Comments
 (0)