通过确定游戏中最有价值的用户获取渠道,做出明智的营销决策。使用 Google Play Install Referrer 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); } }