Skip to content

User Identification

The library manages user sessions and identity tracking automatically via cookies and the Segmentify API.

View as Markdown llms.txt

Every event is enriched with two IDs managed as cookies:

CookieLifetimePurpose
_sgf_session_id24 hoursIdentifies a single browsing session
_sgf_user_id1 yearPersists across sessions for returning users

These are created automatically on the first event. If either is missing, the library fetches new IDs from the Segmentify API.

You can associate tracked behavior with a known user via:

  • user in config — set at initialization (see Configuration)
  • email / externalId in event payloads — passed on any event call
  • Register, LogIn, Identify events — dedicated user operations (see Events)

The library detects the user’s device automatically using the Bowser library:

PlatformValue
Desktop'PC'
Mobile'mobile'
Tablet'tablet'

This is included in every event payload as part of the enriched ExtendedPayload, along with OS name, OS version, and browser.