Android-可以通过编程安装转介器



我已经注意到浏览器中的某些Google Play应用链接具有referrer=属性,这显然告诉您将您发送到Google Play中该应用程序的页面。

是否可以在我的应用程序的代码中看到转介程序(如果有)?如果没有,请在任何地方看到它?

您可以使用com.android.vending.INSTALL_REFERRER

Google Play com.android.vending.install_referrer意图是 从Google Play商店安装应用程序时广播。

将此接收器添加到AndroidManifest.xml

<receiver
    android:name="com.example.android.InstallReferrerReceiver"
    android:exported="true"
    android:permission="android.permission.INSTALL_PACKAGES">
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
</receiver>

创建一个broadcastreceiver:

public class InstallReferrerReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        String referrer = intent.getStringExtra("referrer");
        //Use the referrer
    }
}

您可以按照此答案的步骤测试转介跟踪。

使用Google Play推荐人API(2017年11月20日)

InstallReferrerClient mReferrerClient
...
mReferrerClient = newBuilder(this).build();
mReferrerClient.startConnection(this);
@Override
public void onInstallReferrerSetupFinished(int responseCode) {
   switch (responseCode) {
       case InstallReferrerResponse.OK:
           try {
               ReferrerDetails response = mReferrerClient.getInstallReferrer();
               String referrer = response.getInstallReferrer()
               mReferrerClient.endConnection();
           } catch (RemoteException e) {
               e.printStackTrace();
           }
           break;
       case InstallReferrerResponse.FEATURE_NOT_SUPPORTED:
           Log.w(TAG, "InstallReferrer not supported");
           break;
       case InstallReferrerResponse.SERVICE_UNAVAILABLE:
           Log.w(TAG, "Unable to connect to the service");
           break;
       default:
           Log.w(TAG, "responseCode not found.");
   }
}

广告系列参数用于传递有关将用户转介到您应用程序的Google Play商店页面中的广告系列或流量源的信息,将其引入您的应用程序的Google Analytics(分析)。/p>

构建了广告系列参数字符串后,将其添加到Google Play商店URL中作为转介参数的值,如此示例:

https://play.google.com/store/apps/details?id=com.example.app
&referrer=utm_source%3Dgoogle
%26utm_medium%3Dcpc
%26utm_term%3Drunning%252Bshoes
%26utm_content%3DdisplayAd1
%26utm_campaign%3Dshoe%252Bcampaign

Google Play商店将转介参数的值传递给您应用程序的Google Analytics(分析实现)。

参考:https://developers.google.com/analytics/devguides/collection/android/v2/campaignshttps://developers.google.com/analytics/devguides/collection/android/v2/campaigns#google-play-play-url-builder

相关内容

最新更新