เอกสารนี้มีไว้สําหรับนักพัฒนาแอปบนอุปกรณ์เคลื่อนที่ และอธิบายวิธีใช้ Google Analytics ในการวัดการโต้ตอบของผู้ใช้และตอบคําถามเกี่ยวกับการใช้งานแอป
บทนำ
Google Analytics สําหรับแอปบนอุปกรณ์เคลื่อนที่มีแพลตฟอร์มเพื่อวัดการโต้ตอบของผู้ใช้ ช่วยให้คุณเข้าใจและเพิ่มประสิทธิภาพการมีส่วนร่วมของผู้ใช้กับแอปได้ดีขึ้น
การใช้งาน Google Analytics ตามค่าเริ่มต้น จะให้ข้อมูลต่อไปนี้เกี่ยวกับแอปของคุณโดยอัตโนมัติ
- จํานวนผู้ใช้และเซสชัน
- ระยะเวลาเซสชัน
- ระบบปฏิบัติการ
- รุ่นอุปกรณ์
- ภูมิศาสตร์
คู่มือนี้จะอธิบายวิธีที่คุณสามารถใช้ฟีเจอร์เพิ่มเติมของ Google Analytics เพื่อให้เข้าใจผู้ใช้และพฤติกรรมของผู้ใช้ได้ดียิ่งขึ้น
ก่อนเริ่มต้น
ก่อนใช้คู่มือนี้เพื่อตั้งค่า Google Analytics สําหรับแอปบนอุปกรณ์เคลื่อนที่
- ติดตั้ง SDK สําหรับแพลตฟอร์มที่คุณกําหนดเป้าหมาย ดังนี้
- อ่านแนวทางปฏิบัติแนะนําสําหรับการตั้งค่า Analytics สําหรับแอปบนอุปกรณ์เคลื่อนที่
ภาพรวม
เหยื่อมังกร
คู่มือนี้ใช้แอปตัวอย่างเพื่อแนะนําวิธีการใช้ฟีเจอร์เพิ่มเติมของ Google Analytics แอปนี้ชื่อว่าตัวจับมังกร และมีลักษณะการเล่นดังต่อไปนี้
- ระดับประกอบด้วยผู้เล่น มังกร พื้นที่ที่มีรั้วล้อมรอบ บ่อน้ํา และต้นไม้
- วัตถุประสงค์ของผู้เล่นคือจับมังกรด้วยการขยับเข้าไปในเขตที่มีรั้ว
- ผู้เล่นสามารถไปที่ส่วนต่างๆ ของระดับและวัตถุต่างๆ เช่น บ่อน้ําหรือต้นไม้วิเศษ
- ผู้เล่นจะก้าวสู่ระดับถัดไปเมื่อจับมังกรตัวอื่นๆ ครบแล้ว
- ผู้เล่นเริ่มเล่นเกมในระดับแรกที่ชื่อว่า Barren Fields
เมื่อใช้ Google Analytics คําถามบางส่วนเกี่ยวกับพฤติกรรมของผู้ใช้ที่สามารถหาคําตอบเกี่ยวกับตัวจับมังกรได้มีดังนี้
- ผู้ใช้ของฉันดําเนินการอะไรบ้าง (เหตุการณ์)
- ผู้ใช้จ่ายเงินเท่าใดในแอปของฉัน (อีคอมเมิร์ซ)
- ผู้ใช้บรรลุวัตถุประสงค์ของแอปของฉันหรือไม่ (เป้าหมาย)
- ผู้ใช้ที่มีลักษณะที่เฉพาะเจาะจงเป็นอย่างไร (มิติข้อมูล/เมตริกที่กําหนดเอง)
- ใช้เวลานานเท่าใดกว่าผู้ใช้จะทํางานเสร็จสมบูรณ์ (การกําหนดเวลาที่กําหนดเอง)
ส่วนที่เหลือของเอกสารนี้แสดงวิธีหาคําตอบสําหรับคําถามเหล่านี้โดยการนําฟีเจอร์ของ Google Analytics ไปใช้กับเกมตัวจับมังกร
ผู้ใช้ของฉันดําเนินการอะไรบ้าง (กิจกรรม)
หากมีการกระทําสําคัญที่คุณต้องการติดตามภายในแอป
คุณสามารถใช้เหตุการณ์เพื่ออธิบายการกระทํานี้ใน Google Analytics เหตุการณ์ประกอบด้วยพารามิเตอร์ 4 ตัว ได้แก่ category
, action
, label
และ value
ตัวอย่างเช่น ในตัวจับมังกร ผู้ใช้ช่วยชีวิตมังกรหรือไปเล่นยังด่านใดด่านหนึ่งในระดับสําคัญเป็นการกระทําที่เราต้องการวัดโดยใช้เหตุการณ์ ข้อมูลโค้ดด้านล่างแสดงวิธีการวัดค่านี้ใน Google Analytics
Android SDK
// To determine how many dragons are being rescued, send an event when the // player rescues a dragon. tracker.send(new HitBuilders.EventBuilder() .setCategory("Barren Fields") .setAction("Rescue") .setLabel("Dragon") .setValue(1) .build()); // To determine if players are visiting the magic tree, send an event when the // player is in the vicinity of the magic tree. tracker.send(new HitBuilders.EventBuilder() .setCategory("Barren Fields") .setAction("Visited") .setLabel("Magic Tree") .setValue(1) .build()); // To determine if players are visiting the well, send an event when the player // is in the vicinity of the well. tracker.send(new HitBuilders.EventBuilder() .setCategory("Barren Fields") .setAction("Visited") .setLabel("Well") .setValue(1) .build());
iOS SDK
// To determine how many dragons are being rescued, send an event when the // player rescues a dragon. [tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"Barren Fields" action:@"Rescue" label:@"Dragon" value:@1] build]]; // To determine if players are visiting the magic tree, send an event when the // player is in the vicinity of the magic tree. [tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"Barren Fields" action:@"Visited" label:@"Magic Tree" value:@1] build]]; // To determine if players are visiting the well, send an event when the player // is in the vicinity of the well. [tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"Barren Fields" action:@"Visited" label:@"Well" value:@1] build]];
ปลั๊กอิน GA สําหรับ Unity
// To determine how many dragons are being rescued, send an event when the // player rescues a dragon. googleAnalytics.LogEvent("Barren Fields", "Rescue", "Dragon", 1); // To determine if players are visiting the magic tree, send an event when the // player is in the vicinity of the magic tree. googleAnalytics.LogEvent("Barren Fields", "Visited", "Magic Tree", 1); // To determine if players are visiting the well, send an event when the player // is in the vicinity of the well. googleAnalytics.LogEvent("Barren Fields", "Visited", "Well", 1);
มิตรภาพและความสําเร็จในการวัดผล
เมตริกของผู้เล่นและความสําเร็จจะวัดได้โดยใช้เหตุการณ์ใน Google Analytics เช่น หากต้องการวัดรางวัลพิเศษที่กอบกู้มังกร 5 ตัว จํานวนมังกรที่ผู้เล่นช่วยได้จะมีการบันทึก จากนั้นเมื่อผู้เล่นมาถึงเกณฑ์ ระบบจะส่งเหตุการณ์ไปยัง Google Analytics:
Android SDK
if (numDragonsRescued > 5) { if (!user.hasAchievement(RESCUED_ACHIEVEMENT) { tracker.send(new HitBuilders.EventBuilder() .setCategory("Achievement") .setAction("Unlocked") .setLabel("5 Dragons Rescued") .setValue(1) .build()); } else { tracker.send(new HitBuilders.EventBuilder() .setCategory("Achievement") .setAction("Earned") .setLabel("5 Dragons Rescued") .setValue(1) .build()); } }
iOS SDK
if (numDragonsRescued > 5) { if (![user hasAchievement:RESCUED_ACHIEVEMENT]) { [tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"Achievement" action:@"Unlocked" label:@"5 Dragons Rescued" value:@1] build]]; } else { [tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"Achievement" action:@"Earned" label:@"5 Dragons Rescued" value:@1] build]]; } }
ปลั๊กอิน GA สําหรับ Unity
if (numDragonsRescued > 5) { if (!user.HasAchievement(RESCUED_ACHIEVEMENT)) { googleAnalytics.LogEvent("Achievement", "Unlocked", "5 Dragons Rescued", 1); } else { googleAnalytics.LogEvent("Achievement", "Earned", "5 Dragons Rescued", 1); } }
คู่มือนักพัฒนาซอฟต์แวร์สําหรับกิจกรรม
การรายงานเหตุการณ์
ข้อมูลกิจกรรมจะอยู่ใน
- อินเทอร์เฟซบนเว็บในส่วน Gg;;gt;> Event >> เหตุการณ์ยอดนิยม
- รายงานที่กําหนดเอง
- Core Reporting API
ผู้ใช้จ่ายเงินเท่าใดในแอปของฉัน (อีคอมเมิร์ซที่เพิ่มประสิทธิภาพ)
หากต้องการวัดการซื้อในแอปของผู้ใช้ ให้ใช้การติดตามอีคอมเมิร์ซเพื่อติดตามการซื้อและทําความเข้าใจประสิทธิภาพผลิตภัณฑ์และพฤติกรรมของผู้ใช้ที่เกี่ยวข้อง การติดตามอีคอมเมิร์ซสามารถใช้เพื่อวัดการซื้อสินค้าที่เฉพาะเจาะจงหรือสกุลเงินเสมือน
ตัวอย่างเช่น ในตัวจับมังกร ระบบจะส่งข้อมูลธุรกรรมไปยัง Google Analytics พร้อมด้วยเหตุการณ์ เพื่อวัดการซื้อของบางรายการ
Android SDK
Product product = new Product() .setName("Dragon Food") .setPrice(40.00); ProductAction productAction = new ProductAction(ProductAction.ACTION_PURCHASE) .setTransactionId("T12345"); // Add the transaction data to the event. HitBuilders.EventBuilder builder = new HitBuilders.EventBuilder() .setCategory("In-Game Store") .setAction("Purchase") .addProduct(product) .setProductAction(productAction); // Send the transaction data with the event. tracker.send(builder.build());
iOS SDK
GAIEcommerceProduct *product = [[GAIEcommerceProduct alloc] init]; [product setName:@"Dragon Food"]; [product setPrice:@40.00]; GAIEcommerceProductAction *productAction = [[GAIEcommerceProductAction alloc] init]; [productAction setAction:kGAIPAPurchase]; [productAction setTransactionId:@"T12345"]; GAIDictionaryBuilder *builder = [GAIDictionaryBuilder createEventWithCategory:@"In-Game Store" action:@"Purchase" label:nil value:nil]; // Add the transaction data to the event. [builder setProductAction:productAction]; [builder addProduct:product]; // Send the transaction data with the event. [tracker send:[builder build]];
ปลั๊กอิน GA สําหรับ Unity
// Note: Using Android SDK v3 and standard Ecommerce tracking. googleAnalytics.LogItem("T12345", "Dragon Food", "Food_SKU", "Items", 40.00, 1); googleAnalytics.LogTransaction("T12345", "In-Game Store", 40.00, 0.00, 0.00);
หากผู้ใช้ซื้อสกุลเงินเสมือน เราขอแนะนําให้คุณวัดการแลกเปลี่ยนเงินจริงเมื่อส่งข้อมูลธุรกรรมไปยัง Google Analytics เมื่อผู้ใช้ใช้สกุลเงินเสมือนเพื่อซื้อสินค้า ให้วัดสิ่งนี้โดยใช้เหตุการณ์ เช่น
Android SDK
/** * When the user purchases the virtual currency (Gems) measure the transaction * using enhanced ecommerce. */ Product product = new Product() .setName("2500 Gems") .setPrice(5.99); ProductAction productAction = new ProductAction(ProductAction.ACTION_PURCHASE) .setTransactionId("T67890"); // Add the transaction to the screenview. HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder() .addProduct(product) .setProductAction(productAction); // Send the transaction with the screenview. tracker.setScreenName("In-Game Store"); tracker.send(builder.build()); /** * When the user purchases an item using the virtual currency (Gems) send an * event to measure this in Google Analytics. */ HitBuilders.EventBuilder builder = new HitBuilders.EventBuilder() .setCategory("In-Game Store") .setAction("Purchase") .setLabel("Sword") .setValue(35); tracker.send(builder.build());
iOS SDK
/** * When the user purchases the virtual currency (Gems) measure the transaction * using enhanced ecommerce. */ GAIEcommerceProduct *product = [[GAIEcommerceProduct alloc] init]; [product setName:@"2500 Gems"]; [product setPrice:@5.99]; GAIEcommerceProductAction *productAction = [[GAIEcommerceProductAction alloc] init]; [productAction setAction:kGAIPAPurchase]; [productAction setTransactionId:@"T67890"]; GAIDictionaryBuilder *viewBuilder = [GAIDictionaryBuilder createScreenView]; // Add the transaction data to the screenview. [viewBuilder setProductAction:productAction]; [viewBuilder addProduct:product]; // Send the transaction with the screenview. [tracker set:kGAIScreenName value:@"In-Game Store"]; [tracker send:[viewBuilder build]]; /** * When the user purchases an item using the virtual currency (Gems) send an * event to measure this in Google Analytics. */ GAIDictionaryBuilder *eventBuilder = [GAIDictionaryBuilder createEventWithCategory:@"In-Game Store" action:@"Purchase" label:@"Sword" value:@35]; [tracker send:[eventBuilder build]];
ปลั๊กอิน GA สําหรับ Unity
// Note: Using Android SDK v3 and standard Ecommerce tracking. /** * When the user purchases the virtual currency (Gems) measure the transaction * using enhanced ecommerce. */ googleAnalytics.LogItem("T12345", "2500 Gems", "GEM2500_SKU", "Items", 5.99, 1); googleAnalytics.LogTransaction("T12345", "In-Game Store", 5.99, 0.00, 0.00); /** * When the user purchases an item using the virtual currency (Gems) send an * event to measure this in Google Analytics. */ googleAnalytics.LogEvent("In-Game Store", "Purchase", "Sword", 35);
คู่มือนักพัฒนาซอฟต์แวร์สําหรับอีคอมเมิร์ซที่เพิ่มประสิทธิภาพ
- การติดตามอีคอมเมิร์ซที่เพิ่มประสิทธิภาพ - Android SDK
- การติดตามอีคอมเมิร์ซที่เพิ่มประสิทธิภาพ - iOS SDK
- อีคอมเมิร์ซ - ปลั๊กอิน GA สําหรับ Unity
การรายงานสําหรับอีคอมเมิร์ซที่เพิ่มประสิทธิภาพ
ข้อมูลอีคอมเมิร์ซมีให้บริการใน
ผู้ใช้บรรลุวัตถุประสงค์ของแอปของฉันหรือไม่ (เป้าหมาย)
หากคุณมีวัตถุประสงค์เฉพาะสําหรับแอปที่คุณต้องการให้ผู้ใช้ดําเนินการ คุณสามารถกําหนดและวัดวัตถุประสงค์เหล่านี้ได้โดยใช้เป้าหมายใน Google Analytics ตัวอย่างเช่น เป้าหมายอาจเป็นการทําให้ผู้ใช้เล่นเกมถึงระดับหนึ่งๆ หรือซื้อไอเทมหนึ่งๆ ดูข้อมูลเพิ่มเติมเกี่ยวกับวิธีการทํางานของเป้าหมายได้ที่เกี่ยวกับเป้าหมาย (ศูนย์ช่วยเหลือ)
ในเกมตัวจับมังกร คุณสามารถตั้งเป้าหมาย เพื่อวัดผลเมื่อมีการซื้อในแอปหากส่งเหตุการณ์ไปยัง Google Analytics สําหรับการซื้อแต่ละครั้ง คุณกําหนดเป้าหมายได้ในผู้ดูแลระบบเว็บอินเทอร์เฟซโดยไม่ต้องใช้พารามิเตอร์ใดๆ เพิ่มเติม โดยใช้พารามิเตอร์ต่อไปนี้
- ประเภทเป้าหมาย (เท่ากับ): เหตุการณ์
- หมวดหมู่ (เท่ากับ): ในเกม
- การกระทํา (เท่ากับ): การซื้อ
- ใช้มูลค่าเหตุการณ์เป็นมูลค่าเป้าหมายสําหรับ Conversion: Yes
การรายงานเป้าหมาย
ข้อมูลเป้าหมายมีอยู่ใน
- อินเทอร์เฟซเว็บใน Conversion >> เป้าหมาย >> ภาพรวม
- รายงานที่กําหนดเอง
- Core Reporting API
ผู้ใช้มีลักษณะที่เฉพาะเจาะจงอย่างไร (มิติข้อมูลที่กําหนดเอง &เมตริก)
หากต้องการติดตามผู้ใช้ด้วยแอตทริบิวต์/ลักษณะเฉพาะ/ข้อมูลเมตาที่เฉพาะเจาะจง สามารถใช้มิติข้อมูลที่กําหนดเองเพื่อส่งข้อมูลประเภทนี้ไปยัง Google Analytics และในการวิเคราะห์ได้ ดูข้อมูลเพิ่มเติมเกี่ยวกับวิธีการทํางานของมิติข้อมูลที่กําหนดเองได้ที่มิติข้อมูลและเมตริกที่กําหนดเอง ข้อมูลอ้างอิงของเมตริก
ตัวอย่างเช่น ในตัวจับมังกร เพื่อดูเปอร์เซ็นต์ของผู้ใช้ที่อยู่ในระดับแรก ระดับที่ 2 เป็นต้น คุณสามารถตั้งมิติข้อมูลที่กําหนดเองกับระดับปัจจุบันของผู้ใช้ และส่งไปยัง Google Analytics ขั้นตอนมีดังต่อไปนี้
- สร้างมิติข้อมูลที่กําหนดเองซึ่งมีขอบเขต
User
มีการใช้ขอบเขตUser
เนื่องจากค่านี้ควรคงอยู่ในทุกเซสชันของผู้ใช้ดังกล่าว ดูตั้งค่าหรือแก้ไขมิติข้อมูลที่กําหนดเอง (ศูนย์ช่วยเหลือ) - อัปเดตค่ามิติข้อมูลที่กําหนดเองเมื่อระดับของผู้ใช้มีการเปลี่ยนแปลง
ข้อมูลโค้ดต่อไปนี้จะแสดงวิธีการอัปเดตสถานะของผู้ใช้ใน Google Analytics ซึ่งดัชนีมิติข้อมูลที่กําหนดเองระดับผู้ใช้คือ 1
และ
ระดับของผู้ใช้เปลี่ยนเป็น Barren Fields
Android SDK
// Set the user level custom dimension when sending a hit to Google Analytics // such as a screenview or event. tracker.setScreenName("BarrenFields"); tracker.send(new HitBuilders.ScreenViewBuilder() .setCustomDimension(1, "Barren Fields") .build() );
iOS SDK
// Set the user level custom dimension when sending a hit to Google Analytics // such as a screenview or event. [tracker set:kGAIScreenName value:@"BarrenFields"]; [tracker send:[[[GAIDictionaryBuilder createScreenView] set:@"Barren Fields" forKey:[GAIFields customDimensionForIndex:1]] build]];
ปลั๊กอิน GA สําหรับ Unity
// Set the user level custom dimension when sending a hit to Google Analytics // such as a screenview or event. googleAnalytics.LogScreen(new AppViewHitBuilder() .SetScreenName("BarrenFields").SetCustomDimension(1, "Barren Fields"));
คู่มือนักพัฒนาซอฟต์แวร์สําหรับมิติข้อมูลและ AMP ที่กําหนดเอง เมตริก
- มิติข้อมูลที่กําหนดเอง &เมตริก - Android SDK
- มิติข้อมูลที่กําหนดเอง &เมตริก - iOS SDK
- มิติข้อมูลที่กําหนดเองและเมตริก - ปลั๊กอิน GA สําหรับ Unity
การรายงานสําหรับมิติข้อมูลที่กําหนดเองและ เมตริก
คุณรวมมิติข้อมูลที่กําหนดเองและนําไปใช้เป็นกลุ่มเพื่อทําสิ่งต่อไปนี้ได้
- รายงานมาตรฐานส่วนใหญ่ในอินเทอร์เฟซแบบเว็บ
- รายงานที่กําหนดเอง
- Core Reporting API
การใช้มิติข้อมูลที่กําหนดเองเป็นกลุ่มจะช่วยให้คุณสามารถวิเคราะห์ผู้ใช้ที่อยู่ในด่านหนึ่งๆ ในเกมได้
ต้องใช้เวลานานเท่าใดกว่าผู้ใช้จะทํางานเสร็จ (การกําหนดเวลาที่กําหนดเอง)
หากต้องการวัดระยะเวลาที่แอปใช้ทํางาน ระยะเวลาของผู้ใช้สามารถใช้สําหรับการวัดที่อิงตามเวลาใน Google Analytics ช่วงเวลาของผู้ใช้คล้ายกับเหตุการณ์ แต่อิงตามเวลา และอาจมี
category
, value
, name (variable)
และ
label
หากต้องการดูวิธีการทํางานของเวลาของผู้ใช้ โปรดดูหัวข้อเกี่ยวกับความเร็วเว็บไซต์
ตัวอย่างเช่น ในตัวจับมังกรที่ใช้เวลานานเท่าใดกว่าที่ผู้ใช้จะช่วยเหลือมังกรตัวแรก คุณสามารถส่งบางอย่างได้ เช่น
Android SDK
// Build and send a timing hit. tracker.send(new HitBuilders.TimingBuilder() .setCategory("Barren Fields") .setValue(45000) // 45 seconds. .setVariable("First Rescue") .setLabel("Dragon") .build());
iOS SDK
[tracker send:[[GAIDictionaryBuilder createTimingWithCategory:@"Barren Fields" interval:@45000 // 45 seconds. name:@"First Rescue" label:@"Dragon"] build]];
ปลั๊กอิน GA สําหรับ Unity
// Build and send a timing hit. googleAnalytics.LogTiming("Barren Fields",45000,"First Rescue","Dragon");
คู่มือนักพัฒนาซอฟต์แวร์สําหรับระยะเวลาที่กําหนดเอง
- ระยะเวลาของผู้ใช้ - Android SDK
- ระยะเวลาของผู้ใช้ - iOS SDK
- ระยะเวลาของผู้ใช้ - ปลั๊กอิน GA สําหรับ Unity
การรายงานสําหรับระยะเวลาที่กําหนดเอง
ข้อมูลเวลาที่กําหนดเองมีอยู่ใน
- อินเทอร์เฟซบนเว็บใน GGID ความเร็วพฤติกรรม
- รายงานที่กําหนดเอง
- Core Reporting API
แหล่งข้อมูลที่เกี่ยวข้อง
- Analytics Academy - พัฒนาทักษะ Analytics ด้วยหลักสูตรออนไลน์ฟรี ซึ่งรวมถึงพื้นฐานการวิเคราะห์แอปบนอุปกรณ์เคลื่อนที่
- API การรวบรวมและ SDK - ดูวิธีต่างๆ ในการส่งข้อมูลไปยัง Google Analytics