Session Management
Generate the userId and sessionId that every event must carry.
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
Generating IDs with Segmentify
Section titled “Generating IDs with Segmentify”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.comUse the count parameter based on what you need:
count=1returns one key forsessionIdcount=2returns two keys for bothuserIdandsessionId
Example requests
Section titled “Example requests”GET https://xxx.segmentify.com/get/key?count=1Returns one key to use as sessionId.
GET https://xxx.segmentify.com/get/key?count=2Returns two keys to use as userId and sessionId.
Example response
Section titled “Example response”If you request two keys, the response will look like this:
["XXXXXXXXXXXXXXXXXXXXXXX","YYYYYYYYYYYYYYYYYYYY"]Recommended mapping:
- first value ->
userId - second value ->
sessionId
Alternative approach
Section titled “Alternative approach”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
userIdmust uniquely identify a user - each
sessionIdmust uniquely identify a session
Recommended flow
Section titled “Recommended flow”- Check whether the visitor already has a
userId. - If not, request 2 keys and store them as
userIdandsessionId. - If the visitor already has a
userIdbut starts a new visit, request 1 key for a newsessionId. - Include both
userIdandsessionIdin every event.
Request SessionId
Section titled “Request SessionId”GET /get/key
See this endpoint in the Events API reference.
Request UserId and SessionId
Section titled “Request UserId and SessionId”GET /get/key
See this endpoint in the Events API reference.