本文档将大略介绍与 iOS 版 Google Analytics(分析)SDK v3 有关的会话。
概览
会话表示用户与您的应用互动的单段过程。会话是一种很有用的容器,可帮助您衡量屏幕浏览、事件和电子商务交易等活动。
管理会话
默认情况下,Google Analytics(分析)会将相互间隔不到 30 分钟的匹配归到同一个会话中。此间隔可在媒体资源一级进行配置。了解如何配置此会话超时时长。
手动会话管理
要手动开始或结束一个会话,请在您传递到跟踪器 send: 方法的字典中设置会话控制参数。
// May return nil if a tracker has not yet been initialized. id tracker = [[GAI sharedInstance] defaultTracker]; // Start a new session with a screenView hit. GAIDictionaryBuilder *builder = [GAIDictionaryBuilder createScreenView]; [builder set:@"start" forKey:kGAISessionControl]; [tracker set:kGAIScreenName value:@"My Screen"]; [tracker send:[builder build]];
// There should be no need to end a session explicitly. However, if you do // need to indicate end of session with a hit, simply add the following line // of code to add the parameter to the builder: [builder set:@"end" forKey:kGAISessionControl];