Skip to content

Session Management

Generate the userId and sessionId that every event must carry.

View as Markdown llms.txt

Every event must include both userId and sessionId.

These two fields are used together to uniquely identify:

  • the user in your store
  • the user’s current session during their visit

You can generate these IDs by sending a GET request to your account-specific data center URL using this endpoint:

/get/key?count=

You can find your data center URL in Account Settings -> Integrations.

Example data center URL:

https://xxx.segmentify.com

Use the count parameter based on what you need:

  • count=1 returns one key for sessionId
  • count=2 returns two keys for both userId and sessionId
GET https://xxx.segmentify.com/get/key?count=1

Returns one key to use as sessionId.

GET https://xxx.segmentify.com/get/key?count=2

Returns two keys to use as userId and sessionId.

If you request two keys, the response will look like this:

["XXXXXXXXXXXXXXXXXXXXXXX","YYYYYYYYYYYYYYYYYYYY"]

Recommended mapping:

  • first value -> userId
  • second value -> sessionId

You can also generate your own IDs instead of requesting them from Segmentify.

If you use your own IDs:

  • they can be any string
  • each userId must uniquely identify a user
  • each sessionId must uniquely identify a session
  1. Check whether the visitor already has a userId.
  2. If not, request 2 keys and store them as userId and sessionId.
  3. If the visitor already has a userId but starts a new visit, request 1 key for a new sessionId.
  4. Include both userId and sessionId in every event.

GET /get/key

See this endpoint in the Events API reference.

GET /get/key

See this endpoint in the Events API reference.