เซสชัน - iOS SDK

เอกสารนี้จะแสดงภาพรวมระดับสูงของเซสชันเนื่องจากเกี่ยวข้องกับ Google Analytics SDK สำหรับ iOS v3

ภาพรวม

เซสชันแสดงถึงช่วงเวลาหนึ่งของการโต้ตอบของผู้ใช้กับแอป เซสชันทำหน้าที่เป็นคอนเทนเนอร์ที่มีประโยชน์ของกิจกรรมที่วัดได้ ซึ่งรวมถึงการดูหน้าจอ เหตุการณ์ และธุรกรรมอีคอมเมิร์ซ

การจัดการเซสชัน

โดยค่าเริ่มต้น Google Analytics จะจัดกลุ่ม Hit ที่ได้รับซึ่งกันและกันภายใน 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];