Track sessions
Session Measurement and Tracking in Mobile and Web Applications
How devtodev SDK tracks sessions
Session measurement is an important metric for product analysis as it allows us to determine how frequently and for how long users interact with our website or application. However, it is important to note that session tracking methods on mobile and web applications have their own peculiarities.
When a user starts a session in the application, the SDK recognizes that the application is active, indicating that it has gained focus (when the app is brought into the foreground). If the last recorded activity was more than 10 minutes ago, a Session Start event is sent.
Application activity refers to the period of time when the application is in focus, meaning the application or web page is open and the device screen is active. The focus is lost if the application goes into the background or if another website is opened in the current tab.
We measure the duration of application activity using a technical event called User Engagement (UE). It starts counting the time as soon as the application receives focus and sends the activity counter data to the server.
If, for any reason, the information about the duration of the activity could not be sent, it will be sent the next time the application is initialized and has internet access. However, the activity will only be included in devtodev reports if it has been less than 7 days since the session, as events from a previous period more than 7 days ago are ignored.
Thus, we have information about "Session start" and the duration of activity, but there is no specific "Session end" event.
All events performed by the user are marked with the session start date on which they occurred (sessionid
field in SQL tables).
Platform specifics
Mobile applications
It is difficult to determine the beginning and end of a session because users often switch between screens of different applications. If an application on a mobile device receives focus and the last active time (in focus) was more than 10 minutes ago, a new session will start and a Session Start event will be sent to devtodev.
For example, the user opens the application, spends a minute in it, and then puts the application in the background, a Session Start event will be sent to devtodev in the first second. After a minute, when the application goes into the background or is closed, an event with information about the duration of activity (UE) will be sent to the server as the focus is lost.
Web projects
It is not possible to detect when the user closes the page. Therefore, the UE event (duration of activity) is sent to the server every 2 minutes. To minimize the loss of information about the session duration to no more than two minutes in case of session termination, the SDK additionally saves the duration every 5 seconds and will send the information about the last duration upon the next activity. If there is no next session, the information about the last two minutes may be lost.
Let's consider an example where a user opens a webpage, spends 1.5 minutes on it, then opens another page on the site and spends another 1.5 minutes there.
A Session Start event will be sent in the first second, and every 5 seconds, information about the activity will be saved. After 2 minutes from the start of the session, a UE event with 2 minutes of activity will be sent to the server, and after the third minute, the activity of 1 minute will be recorded in the Local Storage. Information about this activity will be sent during the next user session.
Windows
The SDK cannot control app activity for Windows Standalone projects hence this responsibility is passed on to the developer. During the SDK initialization, the activity is triggered automatically, and later the activity status will not change automatically.
For tracking app activity, the developer can use the DTDAnalytics.StartActivity
and DTDAnalytics.StopActivity
methods.
It is recommended that you use the DTDAnalytics.StopActivity
method to stop the activity when the app goes into the background or being closed. If the window is re-opened from the taskbar it is recommended to renew the activity by using the DTDAnalytics.StartActivity
method.
Session metrics in reports
Session duration – average session time of one user. Calculated as (Total Sessions Length / Number of sessions) averaged by users.
Number of sessions – average number of sessions per user. Calculated as the Number of sessions divided by the Number of users.
Total daily time spent – average total time per day spent in the user application. Calculated as Total Sessions Length divided by the number of Active Users.
Sessions - total number of sessions (opening or unfolding the application) for the given time period.
Sessions by user – average number of sessions made by one user during the period.
Average session length – calculated from the data obtained from session starts and user activity time during those sessions. It is defined as the sum of the length of all sessions divided by the number of sessions within a given period.
Session metrics in SQL
SQL Wizard
In the SQL wizard, there is a parameter called session.Duration
, which is tracked by the UE event. The session.Duration
parameter represents the duration of the activity, i.e., the time the application is in focus, and it is not equal to the session duration.
sessions.Count
is the number of Session Start events received from the user.
SQL Editor
ss: represents the Session Start event received from the user.
ue: represents User Engagement – the time that the application was in focus (active), providing information about time parameters and activity duration.
From this data, you can calculate the average session length by dividing the sum of activity lengths from all rows for the desired period by the sum of all session starts for the same period. We recommend using extended time periods to obtain a more reliable result.
Last updated
Was this helpful?