Google Play Install Referrer

找出遊戲最有效益的使用者獲取管道,做出明智的行銷決策。使用 Google Play 安裝參照網址 API,以可靠的方式追蹤應用程式的參照資訊。

追蹤推薦資料可協助您瞭解哪些流量來源為 Google Play 商店帶來最多應用程式下載量。這些洞察資料可協助您充分運用廣告支出,並盡量提高投資報酬率。

命名空間: PlayPcSdkManaged.InstallReferrer

用戶端類別: InstallReferrerClient

商店資訊頁面的連結

首先,請將使用者連結至應用程式的 Google Play 商店頁面。在網址中加入下列查詢參數:

  • id:遊戲的 Play 套件名稱
  • referrer:代表推薦連結來源的字串。應用程式安裝並執行後,即可查詢這個字串。
https://play.google.com/store/apps/details?id=com.example.package&referrer=example_referrer_source

建立用戶端

請務必使用工廠建立 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 API,判斷促成安裝的流量來源。

使用 GetInstallReferrerAsync 查詢推薦者詳細資料。回應會包含傳遞至商店資訊頁面 referrer 查詢參數的相同字串。

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);
    }
}