Menu
Amazon Mobile Analytics
User Guide

Managing Sessions

Before you manage sessions in your app, you must:

Users Engage in Sessions

Mobile Analytics reports app usage data based on activity captured in sessions. A session is a period of time during which the application is active on the device. A session begins when an app is launched or brought to the foreground, and ends when the app is terminated or goes to the background. To accommodate brief interruptions, like a text message, an inactivity period of up to 5 seconds does not counted as a new session.

Collecting KPI Data

Mobile Analytics tracks sessions and events submitted during each session to generate the collection of standard charts in the console reporting on key performance indicators (KPIs). Total Daily Sessions shows the number of sessions your app has each day. Average Sessions per Daily Active User shows the mean number of sessions per user per day.

Starting a Session

When your app starts, a session tracked by Mobile Analytics should begin. The code that initializes the app calls the PutEvents action, sending a session start event.

A session start event has an eventType of "_session.start" as shown in the following example.

Copy
POST /2014-06-05/events HTTP/1.1 Host: mobileanalytics.us-east-1.amazonaws.com X-Amz-Date: <Date> Authorization: AWS4-HMAC-SHA256 Credential=<access_key>/20140709/us-east-1/mobileanalytics/aws4_request, SignedHeaders=content-length;content-type;host;user-agent;x-amz-client-context;x-amz-date;x-amz-security-token;x-amz-target, Signature=<signature> User-Agent: <User agent string> x-amz-Client-Context: {"client":{"client_id":"<client_id>","app_title":"<app_title>","app_version_name":"<app_version_name>","app_version_code":"<app_version_code>","app_package_name":"<app_package_name>"},"custom":{},"env":{"platform":"<platform>","model":"<model>","make":"<make>","platform_version":"<platform_version>","locale":"<locale>”}} x-amz-security-token: <Security token> Content-Type: application/json Content-Length: <Payload size bytes> Connection: Keep-Alive { "events": [ { "eventType": "_session.start", "session": { "startTimestamp": "<ISO 8601 date>", "id": "<session id>" }, "timestamp": "<ISO 8601 date>", "attributes": { <optional> }, "metrics": { <optional> } } ] }

Stopping a Session

When your app closes or is sent to the background, it should end the current session. To end a session, the application code that responds to notification to shut down or pause calls the PutEvents action, sending a session end event.

A session end event has an eventType of "_session.stop" as shown in the following example.

Copy
POST /2014-06-05/events HTTP/1.1 Host: mobileanalytics.us-east-1.amazonaws.com X-Amz-Date: <Date> Authorization: AWS4-HMAC-SHA256 Credential=<access_key>/20140709/us-east-1/mobileanalytics/aws4_request, SignedHeaders=content-length;content-type;host;user-agent;x-amz-client-context;x-amz-date;x-amz-security-token;x-amz-target, Signature=<signature> User-Agent: <User agent string> x-amz-Client-Context: {"client":{"client_id":"<client_id>","app_title":"<app_title>","app_version_name":"<app_version_name>","app_version_code":"<app_version_code>","app_package_name":"<app_package_name>"},"custom":{},"env":{"platform":"<platform>","model":"<model>","make":"<make>","platform_version":"<platform_version>","locale":"<locale>”}} x-amz-security-token: <Security token> Content-Type: application/json Content-Length: <Payload size bytes> Connection: Keep-Alive { "eventType": "_session.stop", "timestamp": "2014-07-09T03:26:38.719Z", "session": { "id": "<session id>", "duration": 497516, "startTimestamp": "2014-07-09T03:17:20.041Z", "stopTimestamp": "2014-07-09T03:25:37.557Z" }, "attributes": {}, "metrics": {} }