Version: 2020.2
LanguageEnglish
  • C#

AnalyticsSessionInfo

class in UnityEngine.Analytics

/

Implemented in:UnityEngine.UnityAnalyticsModule

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Provides access to the Analytics session information for the current game instance.

This class contains static methods for looking up Analytics session information. Note that cumulative statistics are reset if the player re-installs the game.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Analytics;
using System;

public class NewBehaviourScript : MonoBehaviour { void Start() { Debug.Log("Start " + AnalyticsSessionInfo.userId + " " + AnalyticsSessionInfo.sessionState + " " + AnalyticsSessionInfo.sessionId + " " + AnalyticsSessionInfo.sessionElapsedTime); AnalyticsSessionInfo.sessionStateChanged += OnSessionStateChanged; }

void OnSessionStateChanged(AnalyticsSessionState sessionState, long sessionId, long sessionElapsedTime, bool sessionChanged) { Debug.Log("Call " + AnalyticsSessionInfo.userId + " " + sessionState + " " + sessionId + " " + sessionElapsedTime + " " + sessionChanged); } }

Static Properties

customDeviceIdReports the current custom device ID.
customUserIdReports the current custom user ID.
identityTokenThe current user identity token that the Analytics server returns based on AnalyticsSessionInfo.userId.
sessionCountThe number of sessions played since the app was installed.
sessionElapsedTimeThe time elapsed, in milliseconds, since the beginning of the current game session.
sessionFirstRunReports whether the current session is the first session since the player installed the game or application.
sessionIdA random, unique GUID identifying the current game or app session.
sessionStateThe current state of the session.
userIdA random GUID uniquely identifying sessions played on the same instance of your game or app.

Events

identityTokenChangedDispatched when AnalyticsSessionInfo.identityToken is updated by the server.
sessionStateChangedDispatched when the Analytics session state changes.

Delegates

IdentityTokenChangedDefines the delegate signature to handle AnalyticsSettings.IdentityTokenChanged events.
SessionStateChangedDispatched when the Analytics session state changes.