Session start
The session start event opens a media tracking session. It must be the first event sent for any playback. The response returns a session ID that all subsequent events for the same session must include.
A session expires automatically if no events are received for 10 minutes, or if there is no playhead movement for 30 minutes. If a session expires, you must call session start again to obtain a new session ID.
- Prerequisites: None; always the first event
- Associated metric: Media starts
Recommended implementation types
Call sendEvent with eventType: "media.sessionStart" and the required sessionDetails. The response includes the session ID in handle[].payload[].sessionId (type media-analytics:new-session). Store this value and pass it as sessionID in all subsequent events.
| code language-javascript |
|---|
|
Call trackSessionStart with a media object and optional metadata.
| code language-swift |
|---|
|
Call trackSessionStart with a media object and optional metadata.
| code language-kotlin |
|---|
|
Call createMediaSession with the required session details:
| code language-brightscript |
|---|
|
Call the sessionStart endpoint. The response includes the session ID in handle[].payload[].sessionId (type media-analytics:new-session).
| code language-sh |
|---|
|
Legacy implementation types (Analytics-only)
Call trackSessionStart with a media object created using ADB.Media.createMediaObject:
| code language-javascript |
|---|
|
Call trackSessionStart with a media object created using ADBMobile.media.createMediaObject:
| code language-javascript |
|---|
|
Build a media object with adb_media_init_mediainfo and call mediaTrackSessionStart. The optional second argument accepts an associative array of a.media.* metadata keys, or invalid:
| code language-brightscript |
|---|
|
Send a sessionStart POST to the sessions endpoint. The response Location header contains the session ID to use in all subsequent event requests.
| code language-json |
|---|
|
Resuming a session
When resuming a previously closed session (for example, after a cross-device handoff or after the application restores saved playback state), set the resume flag at session start. This causes Analytics to increment Content resumes rather than Media starts.
Recommended implementation types
Add hasResume: true to sessionDetails:
| code language-javascript |
|---|
|
Set the resumed key on the media object before calling trackSessionStart:
| code language-swift |
|---|
|
Set the RESUMED key on the media object before calling trackSessionStart:
| code language-kotlin |
|---|
|
Add "hasResume": true to sessionDetails:
| code language-brightscript |
|---|
|
Add "hasResume": true to sessionDetails:
| code language-sh |
|---|
|
Legacy implementation types (Analytics-only)
Set the MediaResumed key on the media object:
| code language-javascript |
|---|
|
Set the MediaResumed key on the media object:
| code language-javascript |
|---|
|
Set the resumed key on the media object before calling mediaTrackSessionStart:
| code language-brightscript |
|---|
|
Add "media.resume": true to the params object:
| code language-json |
|---|
|