Google Play Install Referrer

ทำการตัดสินใจทางการตลาดโดยมีข้อมูลครบถ้วนด้วยการระบุช่องทางการได้ผู้ใช้ใหม่ที่มีคุณค่ามากที่สุดสําหรับเกม ใช้ Google Play Install Referrer API เพื่อ ติดตามข้อมูลการอ้างอิงของแอปได้อย่างน่าเชื่อถือ

การติดตามข้อมูลการอ้างอิงจะช่วยให้คุณทราบว่าแหล่งที่มาของการเข้าชมใดที่ส่งผู้ใช้จำนวนมากที่สุดให้ดาวน์โหลดแอปจาก Google Play Store ข้อมูลเชิงลึกเหล่านี้จะช่วยให้คุณใช้จ่ายค่าโฆษณาได้อย่างคุ้มค่าและเพิ่ม ROI ได้สูงสุด

เนมสเปซ: PlayPcSdkManaged.InstallReferrer

คลาสไคลเอ็นต์: InstallReferrerClient

ลิงก์ไปยังหน้าข้อมูลสินค้าใน Store

เริ่มต้นด้วยการลิงก์ผู้ใช้ไปยังหน้า Google Play Store ของแอปพลิเคชัน ใน URL ให้ใส่พารามิเตอร์การค้นหาสำหรับ

  • id: ชื่อแพ็กเกจ Play ของเกม
  • referrer: สตริงที่แสดงแหล่งการอ้างอิง คุณจะค้นหาสตริงนี้ได้เมื่อติดตั้งและเรียกใช้แอปพลิเคชันแล้ว
https://play.google.com/store/apps/details?id=com.example.package&referrer=example_referrer_source

สร้างไคลเอ็นต์

ใช้ Factory เพื่อสร้าง InstallReferrerClient เสมอ ซึ่งจะช่วยให้มั่นใจได้ว่าระบบจะลงทะเบียนการเรียกกลับที่ปลอดภัยสำหรับ Unity โดยอัตโนมัติ

using UnityEngine;
using System;
using System.Threading.Tasks;
// Required SDK Namespaces
using PlayPcSdkManaged.InstallReferrer;
using PlayPcSdkManaged.Unity;

public class InstallReferrerManager : MonoBehaviour
{
    private InstallReferrerClient _installReferrerClient;

    public void SetupInstallReferrer()
    {
        try
        {
            // Creates the client with the required UnityInstallReferrerCallbacksHandler
            _installReferrerClient = PlayPcSdkFactory.CreateInstallReferrerClient();
            Debug.Log("Install Referrer Client created successfully.");
        }
        catch (Exception ex)
        {
            Debug.LogError($"Failed to create Install Referrer Client: {ex.Message}");
        }
    }

    private void OnDestroy()
    {
        // Always dispose of the client to clean up native C++ resources
        _installReferrerClient?.Dispose();
    }
}

ส่งคำค้นหา Install Referrer

หลังจากที่ผู้ใช้ติดตั้งและเปิดเกมแล้ว แอปของคุณจะระบุแหล่งที่มาของการเข้าชมที่ทําให้เกิดการติดตั้งได้โดยใช้ Install Referrer API

ค้นหารายละเอียดผู้แนะนำโดยใช้ GetInstallReferrerAsync การตอบกลับมีสตริงเดียวกันกับที่ส่งไปยังพารามิเตอร์การค้นหา referrer ของหน้าข้อมูลสินค้าใน Store ของคุณ

public async Task GetInstallReferrerAsync()
{
    try
    {
        Debug.Log("Querying Install Referrer...");

        // Async call to retrieve referral information
        var result = await _installReferrerClient.GetInstallReferrerAsync();

        if (result.IsOk)
        {
            // On success, access the InstallReferrer and InstallTimeEpochSeconds
            var referrer = result.Value.InstallReferrer;
            var installTime = result.Value.InstallTimeEpochSeconds;

            Debug.Log($"Install Referrer: {referrer}");
            Debug.Log($"Install Time: {installTime}");

            // Attribute your game's installation to an acquisition channel
        }
        else
        {
            // Handle expected API errors (e.g., Error)
            Debug.LogError($"Query Failed: {result.Code} - {result.ErrorMessage}");
        }
    }
    catch (Exception ex)
    {
        Debug.LogException(ex);
    }
}