Logo

Getting started

How to use the configurable app timeout

Datazoom provides flexibility in defining when an application session should end due to user inactivity. Instead of a fixed timeout period, you can configure your Datazoom collector to end an app session after a specific duration of inactivity that suits your application's usage patterns. This allows for more accurate session tracking aligned with how users interact with your app.

  • Accurate Session Measurement: Define session boundaries that truly reflect user engagement with your specific application.

  • Customizable: Align session timeouts with your internal metrics or specific application requirements (e.g., longer timeouts for video streaming, shorter for quick interactions).

  • Control: Choose to disable time-based session ending entirely if needed.

How it Works

The session timeout is configured within the Datazoom console on a per-collector basis. The Datazoom SDK installed in your application receives this configuration and monitors user activity. If no tracked activity occurs for the specified "Inactivity Interval," the current session is considered ended. When the user interacts with the application again after this period, a new session automatically begins.

Configuration Steps

  1. Navigate to Collector Configuration. Log in to the Datazoom console and navigate to the specific Collector you wish to configure.

  2. Locate Session Timeout Settings. Scroll down the Collector configuration page to the section titled "Session Timeout". 

  3. Click the dropdown control labeled "Inactivity Interval"

    • Preset Values: Choose from a list of common intervals (e.g., "5 mins", "15 mins", "20 mins", "30 mins", etc.). 

    • Custom Value: You can type a specific number of minutes directly into the field.

    • "None": Select this option to disable the inactivity timeout completely. Sessions will only end based on other factors (e.g., app closure)..

  4. Input Constraints:

    • Minimum: The inactivity interval cannot be less than the collector's configured Heartbeat Interval. If you enter a value lower than the heartbeat, an error message ("Must be greater than or equal to your heartbeat interval") will appear.

    • Maximum: The maximum allowed inactivity interval is 1440 minutes (24 hours).

  5. Save Changes: the SDK will pick up this change on its next configuration refresh.

Handling Session Restarts: SDK Callbacks

When a session ends due to inactivity and a new session starts upon subsequent user interaction, it's crucial to understand how this affects data, particularly custom metadata.

  • Metadata Reset: The Datazoom SDK does not automatically carry over or manage custom metadata from the timed-out session to the newly started session.

  • SDK Notifications: To manage this, the Collector SDK provides callbacks or events to notify your application when a session is terminated due to timeout and when a new one begins.

    1. Look for events/callbacks like onSessionTerminated and onSessionRestarted (Note: Exact names may vary slightly depending on the specific SDK platform - e.g., iOS, Android, Web).

  • Your Responsibility: You must implement logic within these callbacks/listeners in your application code. Use these notifications to:

    1. Detect when a session has ended due to inactivity.

    2. Re-initialize or re-apply any necessary custom metadata (e.g., user ID, content details, custom dimensions) when the new session starts (onSessionRestarted).

JavaScript

// --- In your application code where you integrate the Datazoom SDK ---

// Assuming an event listener setup for the SDK

datazoomSDK.addEventListener('sessionTerminated', (details) => {

  console.log('Datazoom session terminated due to:', details.reason); // e.g., 'inactivity'

  // Perform any cleanup if needed before the user becomes active again.

});

datazoomSDK.addEventListener('sessionRestarted', () => {

  console.log('Datazoom session restarted after inactivity.');

  // CRITICAL: Reset any custom metadata needed for the new session

  datazoomSDK.setMetadata('userId', getCurrentUserId());

  datazoomSDK.setMetadata('contentTitle', getCurrentContentTitle());

  // ... reset other relevant metadata ...

});

// --- End Example ---