首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在Android应用程序中获取Google Play referer

如何在Android应用程序中获取Google Play referer
EN

Stack Overflow用户
提问于 2017-05-10 22:42:13
回答 2查看 12K关注 0票数 8

我们正在开发一个Android应用程序。我们想要追踪我们的定位。基本上,我们想要知道我们的用户是从哪里到达Google play的,方法是在Google Play URL中输入一个单词,然后在应用程序中检索该单词,然后将其发送到我们的服务器。

我们已经安装了谷歌分析到我们的应用程序中,我们能够跟踪用户在谷歌统计板上的应用程序中所做的事情。但是,我们如何使用它来实现我们真正想要的东西呢?我们真的需要把我们的用户数据库和这个词联系起来。

我听说过INSTALL_REFERER,但我真的不知道如何使用它。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-05-11 20:18:46

您正在寻找Campaign Measurement。在文档中,它讨论了使用INSTALL_REFERRER如何帮助您确定哪个来源正在将用户发送到Google Play商店中的应用程序。

这很简单,只需在AndroidManifest中放置一个receiver并修改应用程序的Google Play URL即可。

从文档中:

Google Play活动测量允许您查看哪些活动和流量来源正在发送用户从Google Play商店下载您的应用程序。建议所有开发人员实施Google Play Store Campaign Measurement。

实现Google Play活动属性

当您的应用程序从Google Play Store下载时,Play Store应用程序会在安装期间向您的应用程序广播INSTALL_REFERRER意图。此意图包含用于访问应用程序的Google Play Store页面的链接的referrer参数值(如果存在)。

要将应用程序下载归于活动,您必须将referrer参数添加到指向Google Play商店的任何链接,并将BroadcastReceiver添加到您的应用程序,以接收和设置谷歌分析跟踪器上的intent中包含的活动信息。

建议大多数开发者使用SDK自带的BroadcastReceiver。要使用随附的接收器实施Google Play Store Campaign Measurement:

1.将 Analytics receiver添加到您的 AndroidManifest**.xml文件中。**要将Google Analytics receiver添加到清单中,请复制并粘贴以下标记:

  1. Add Play URL的Google Analytics活动参数

接下来,将referrer参数添加到将直接链接到Google Play Store的任何URL,并将该参数的值设置为描述来源的Google Analytics活动参数字符串,如下例所示:

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

要了解如何构建活动参数字符串,请使用Google Play URL Builder或参考Campaign Parameters参考部分。

测试Google Play活动属性

要在发布应用程序之前验证您的Google Play活动测量实现是否按预期工作,请使用Testing Google Play Campaign Attribution Solution Guide

另外,请参阅此similar post

票数 9
EN

Stack Overflow用户

发布于 2018-08-27 22:25:44

尝试使用Play安装Referrer库

这是一种新的、易于使用且可靠的方式,可以安全地检索安装推荐内容

https://android-developers.googleblog.com/2017/11/google-play-referrer-api-track-and.html

另外,切换到新的referrer API允许更深入地了解用户转换漏斗,保护Google Play Store referrer,最后(也是最重要的),提供的额外数据允许完全消除点击注入

(来源:https://www.adjust.com/blog/eliminating-click-injections-with-google-play-referrer-api/)

示例:

代码语言:javascript
运行
复制
final InstallReferrerClient referrerClient = InstallReferrerClient.newBuilder(YourActivity.this).build();
referrerClient.startConnection(new InstallReferrerStateListener() {

        @Override
        public void onInstallReferrerSetupFinished(int responseCode) {
            switch (responseCode) {
                case InstallReferrerClient.InstallReferrerResponse.OK:

                    try {
                        ReferrerDetails response = referrerClient.getInstallReferrer();
                        String installReferrer = response.getInstallReferrer();

                        // handle referrer string

                    } catch (RemoteException e) {
                        e.printStackTrace();
                    }
                    break;

                case InstallReferrerClient.InstallReferrerResponse.FEATURE_NOT_SUPPORTED:
                    // API not available on the current Play Store app
                    break;
                case InstallReferrerClient.InstallReferrerResponse.SERVICE_UNAVAILABLE:
                    // Connection could not be established
                    break;
            }
        }

        @Override
        public void onInstallReferrerServiceDisconnected() {
            // Try to restart the connection on the next request to
            // Google Play by calling the startConnection() method.
        }
});

将以下行添加到应用程序的build.gradle文件的依赖项部分:

代码语言:javascript
运行
复制
dependencies {
    ...
    compile 'com.android.installreferrer:installreferrer:1.0'
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43895757

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档