TapCub is live — analytics, insights and live chat, free on one platform
Glossary

What is a session ID? How sessions are created, cut and counted

A session ID ties together the actions of one visit or login. Two meanings, how analytics tools cut sessions, an 8-event example that gives 2 to 5 sessions depending on the rules, and why a login session ID must stay out of analytics.

Lucas Hayes Reviewed by Chen Yu Also called session identifier Last updated Nov 19, 2026 Glossary

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.id simply 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.

IdentifierWhat it identifiesTypical lifetimeCreated bySpans devices?
Session IDOne visitMinutes to hours; ends on timeout or ruleAnalytics tool or serverNo
Device IDOne browser or phone installMonths, until storage is clearedBrowser, SDK or OSNo
Visitor IDOne anonymous visitor as the tool sees itDepends on privacy mode: a day, or longerAnalytics toolNo
User IDOne known personAs long as the account existsYour product, at sign-upYes, 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:

RuleA new session starts when…Effect on the session count
Idle timeoutNo event for N minutesShorter N gives more sessions
Maximum durationA session has lasted H hoursOnly affects very long visits
Midnight splitThe calendar day changesAdds one session for people active across midnight
Campaign changeThe campaign parameters of the URL changeMore sessions for people who arrive twice from different campaigns
Source changeThe visitor returns from a different external source mid-visitMore 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.

#TimeGap from the previous event
1Day 1, 09:00
2Day 1, 09:1212 minutes
3Day 1, 09:4028 minutes
4Day 1, 10:2040 minutes
5Day 1, 10:288 minutes
6Day 1, 23:50802 minutes
7Day 2, 00:1020 minutes
8Day 2, 00:2515 minutes

Apply four different rule sets (computed in Python):

RulesSessionsEvents in each sessionEvents per session
Idle 30 minutes33, 2, 32.7
Idle 15 minutes52, 1, 2, 1, 21.6
Idle 30 minutes plus midnight split43, 2, 1, 22.0
Idle 60 minutes25, 34.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.

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. Handle server events. The server interface accepts a session_id up 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.

Lucas Hayes

Data Engineer

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

FAQ

Questions people ask

Short answers to the follow-up questions that come up most.

Still have a question?

Chat with the team behind TapCub — we usually reply within a few hours on business days.

What is a session ID?

A session ID is an identifier that groups the actions belonging to one visit or one login. On the web it can be a secret token that a server uses to recognise a logged-in browser, or a label that an analytics tool uses to group page views into a visit.

What is the difference between a session ID and a user ID?

A session ID identifies one visit and ends on a timeout or rule. A user ID identifies one known person for as long as the account exists. One user has many sessions, and a session only belongs to a person after the visit is linked to that user's ID at login.

How long does a session ID last?

It depends on the rules. Analytics tools commonly end a session after a period without events, often 30 minutes, plus an optional maximum length or midnight split. Login sessions have their own timeouts, which security guidance such as OWASP's sets much shorter for high-value applications.

Is a session ID personal data or a security risk?

An authentication session ID is a credential: anyone holding it can act as the user, so it must be random, kept out of URLs and never copied into analytics. An analytics session ID is only a label, but it can be personal data if it is linked to an identifiable person.

See this number on your own site

Add one script tag for web and apps, and the first reports fill in within minutes.

See your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics