Google市場推廣統計

來源:互聯網
上載者:User

Google Play作為Android最大的應用市場,也存在這推廣等常用的行為,那麼如何統計呢,Google Analytics SDK或者其他的SDK都提供了方法,實際上是可以不需要任何sdk,完全可以自己實現的。
原理是這樣的:當來自Play Store上的應用被安裝之後,Play Store會發送一個指定的廣播給被安裝的包,廣播的action為com.android.vending.INSTALL_REFERRER。內容資料類似於 utm_source%3Dgoooooogggggggggggggle%26utm_medium%3Dcpc%26utm_term%3Dandroid%252Bbrowser%26utm_content%3Dmaxthon%2520browser%2520for%2520android%26utm_campaign%3DYou%2520never%2520know%2520fast.
我們只需要接收這個廣播處理即可。

首先在manifest中增加receiver來接收

 <receiver android:name=".AnalyticsReceiver" android:exported="true" >  <intent-filter>    <action android:name="com.android.vending.INSTALL_REFERRER" />  </intent-filter>   </receiver>

這裡的AnalyticsReceiver是專門接收推廣廣播的。
代碼很簡單

package com.example.installreceiverdemo; import android.content.BroadcastReceiver;import android.content.Context;import android.content.Intent;import android.util.Log; public class AnalyticsReceiver extends BroadcastReceiver { private static final String LOGTAG = AnalyticsReceiver.class.getSimpleName(); @Overridepublic void onReceive(Context context, Intent intent) {Log.i(LOGTAG + "_demo", "analyticsReceiver = " + intent + "data in String = " + intent.getStringExtra("referrer"));} }

這樣基本上就完成了,關於簡單測試,可以使用下列代碼:

        Intent it = new Intent("com.android.vending.INSTALL_REFERRER");        it.setPackage("com.example.installreceiverdemo");        it.putExtra("referrer", "utm_source%3Dgoooooogggggggggggggle%26utm_medium%3Dcpc%26utm_term%3Dandroid%252Bbrowser%26utm_content%3Dmaxthon%2520browser%2520for%2520android%26utm_campaign%3DYou%2520never%2520know%2520fast.");        sendBroadcast(it);

相關文章推薦參考:
https://developers.google.com/analytics/devguides/collection/android/v2/campaigns

http://www.localytics.com/docs/android-market-campaign-analytics/

http://gyurigrell.com/2012/2/21/tracking-install-sources-android-apps

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.