Quick answer
A session ID is an identifier that groups the actions of one visit or login. An authentication session ID is a secret that logs a browser in; an analytics session ID is a label produced by cutting rules such as idle timeout. The same events can yield 2 to 5 sessions depending on those rules.
Two things called a session ID
A session ID is an identifier that ties together several actions that belong to one visit or one login. The same words are used for two different jobs, and mixing them up causes both analytics errors and security errors:
- An authentication (application) session ID is a secret the server gives a browser after login so it can recognise later requests. Whoever holds it can act as the user. It lives in a cookie or token and is covered by security guidance such as the OWASP Session Management Cheat Sheet.
- An analytics session ID is a label that groups a visitor's page views and events into one visit, so you can count visits, measure duration and find entry and exit pages. It is not a secret and does not log anyone in. OpenTelemetry's semantic conventions define the attribute
session.idsimply as a unique ID that identifies a session.
This page is mostly about the second kind, with a section on the first so the two do not get confused. The basic idea of a visit is explained in session. What this page adds is the part that decides whether session numbers can be trusted: how the ID is created, when it ends, and what counts as the same session.
The thesis in one sentence: a session ID does not exist in the data by nature; it is the output of cutting rules. Change the rules and the same events produce a different number of sessions.
Session ID, user ID, device ID and visitor ID
Four identifiers are often listed together. They answer different questions and have different lifetimes.
| Identifier | What it identifies | Typical lifetime | Created by | Spans devices? |
|---|---|---|---|---|
| Session ID | One visit | Minutes to hours; ends on timeout or rule | Analytics tool or server | No |
| Device ID | One browser or phone install | Months, until storage is cleared | Browser, SDK or OS | No |
| Visitor ID | One anonymous visitor as the tool sees it | Depends on privacy mode: a day, or longer | Analytics tool | No |
| User ID | One known person | As long as the account exists | Your product, at sign-up | Yes, after login |
Relations to remember: one user can have many devices; one device has many sessions; one session belongs to one device at a time. For the identifiers themselves, see user ID, device ID and UUID, the common format for generated IDs. A session ID answers "which visit", never "which person"; to say a visit belonged to a person, the visit has to be linked to a user ID after login.
How sessions are cut
An analytics tool cannot see that a visit has ended, because the visitor simply stops sending events. It therefore applies rules to decide when to start a new session. Five rules are common:
| Rule | A new session starts when… | Effect on the session count |
|---|---|---|
| Idle timeout | No event for N minutes | Shorter N gives more sessions |
| Maximum duration | A session has lasted H hours | Only affects very long visits |
| Midnight split | The calendar day changes | Adds one session for people active across midnight |
| Campaign change | The campaign parameters of the URL change | More sessions for people who arrive twice from different campaigns |
| Source change | The visitor returns from a different external source mid-visit | More sessions; attribution moves to the new source |
A user switching accounts on one device is another common trigger. There is no universal default. A 30-minute idle timeout is widely used, but it is a convention, not a law, and OWASP's own guidance for login sessions recommends much shorter idle limits (2–5 minutes for high-value applications, 15–30 minutes for low-risk ones) for a different reason: security, not counting. When two tools disagree on sessions, compare the rules first.
Worked example: the same 8 events, between 2 and 5 sessions
Sample data: one visitor generates 8 events on two consecutive days. Times are in the project's time zone.
| # | Time | Gap from the previous event |
|---|---|---|
| 1 | Day 1, 09:00 | |
| 2 | Day 1, 09:12 | 12 minutes |
| 3 | Day 1, 09:40 | 28 minutes |
| 4 | Day 1, 10:20 | 40 minutes |
| 5 | Day 1, 10:28 | 8 minutes |
| 6 | Day 1, 23:50 | 802 minutes |
| 7 | Day 2, 00:10 | 20 minutes |
| 8 | Day 2, 00:25 | 15 minutes |
Apply four different rule sets (computed in Python):
| Rules | Sessions | Events in each session | Events per session |
|---|---|---|---|
| Idle 30 minutes | 3 | 3, 2, 3 | 2.7 |
| Idle 15 minutes | 5 | 2, 1, 2, 1, 2 | 1.6 |
| Idle 30 minutes plus midnight split | 4 | 3, 2, 1, 2 | 2.0 |
| Idle 60 minutes | 2 | 5, 3 | 4.0 |
One person and eight identical events give anywhere from 2 to 5 sessions, a 2.5× spread. Notice what moves with it: events per session ranges from 1.6 to 4.0, and bounce-style measures such as "single-event sessions" change too (zero under the 60-minute rule, two under the 15-minute rule). Nothing about the visitor changed.
The decision rule: never compare session counts, durations or bounce rates between two tools until you have listed both tools' rules side by side. If you must compare, set the idle timeout equal and decide about midnight and campaign splits in advance. Changing the rule mid-stream breaks trends too, so write down the date it changed.
Security: do not confuse the two IDs
Because both are called session IDs, teams sometimes reuse one for the other. Do not.
- Never send the authentication session ID to an analytics tool. It is a credential. OWASP states that session identifiers need at least 64 bits of entropy, generated by a cryptographically secure random generator, and that the ID should be renewed after a privilege change such as login. It also warns that IDs placed in URLs can be disclosed. An analytics event is often logged and shared, which is the wrong place for a credential.
- Generate analytics session IDs independently. A random value or a UUID is fine. It needs to be unique, not secret, and it should be created without reading anything personal.
- Treat renewal after login as a feature. Security guidance wants a fresh authentication ID when someone logs in. Analytics tools often start a new analytics session at the same moment. Both are normal and neither means the visit was "lost".
Common mistakes
- Counting sessions across browser tabs as separate. Many tools share one session across tabs of the same browser; custom code that creates an ID per tab inflates the count.
- Using the session ID as a person ID. Sessions end and a person returns tomorrow. Use a user ID for people.
- Server events with no session ID. A purchase recorded on the server arrives with no visit to attach to. Either send the visit's ID or leave it out of session metrics; do not invent a new session per order.
- Changing the timeout and comparing trends. The change moves the trend line by itself. Annotate the date.
- Treating "session" in chat as the same thing. A chat conversation and an analytics session are different units, even though one visitor can have both.
How TapCub cuts sessions
Imagine the example above: you see 3 sessions in TapCub and a colleague sees 5 in another tool. Here is how to find out why.
- Read the rules. They are under Sessions & channels on Web analytics › Configuration › Web settings. The defaults are a 30-minute idle timeout (adjustable from 5 to 720 minutes) and a 24-hour maximum (1 to 48 hours). Splitting at midnight and splitting when campaign parameters change are off by default; splitting when the visitor returns from a different external source is on. App and mini program data can override the rules; otherwise they follow the web rules.
- Look at real visits. Open Web analytics › Sessions to sample individual visits and see how they were cut. Midnight-crossing visits are counted on the day they start in totals, while the list shows them on both days.
- Remember what changes are retroactive. Changing 30 to 60 minutes only affects data saved afterwards; sessions already cut are not merged back. Note the date on a chart annotation.
- Know what login does. If the login ID on a device changes, the client switches to a new session marker and a new session starts; the old events stay in the old session.
- Handle server events. The server interface accepts a
session_idup to 32 characters. Events sent without one are not written to the session table, so they do not affect session metrics and a single order is not counted as a new visit.
A chat conversation in TapCub is a separate thing from a statistics session; the two connect through the visitor or user, not through a shared ID.
Sources
Was this explanation clear?
We use your answers to fix and expand this page.
Couldn’t send. Please try again in a minute.
Thanks for the feedback. We’ll use it to improve this page.You’ve already sent feedback on this page. Thanks.

Data Engineer
Writes about event design, data quality, and collection workflows, with verifiable implementation methods for reliable analytics.