如何给自己的手机应用添加Google Analysis

1.申请一个Google Analysis账号,并添加一个用户,得到一个配置ID

2.下载libGoogleAnalytics.jar包,添加到项目中;

3.给自己的项目生成一个链接(好像中文网站中不需要这个链接,有个选项是“不是网站”,直接就是对应用程序的绑定了)

4.配置项目:1)加网络访问权限  2)添加跟踪代码


具体实现如下:

Google Analytics Android SDK.

This SDK enables developers to add Google Analytics tracking to applications.
The tracker code is packaged as a single jar file. Add libGoogleAnalytics.jar
to your project's /libs directory (if using Eclipse right click on the jar in
the libs directory and choose "Build Path" -> "Add to Build Path").
See the samples/SampleApplication application for an illustration of how to use
page tracking and event tracking.


The SDK requires your application to have the following permissions present
in AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />



An Analytics tracking 'visit' is defined as the events and page views generated
between calls to start() and stop() on the GoogleAnalyitcsTracker.
Everytime start() is called a new visit is started.
You should call stop() on GoogleAnalyticsTracker when your application is
closing.


You will need an Analytics Account ID to properly initialize the
GoogleAnalyticsTracker object. We recommend you create a new website profile,
by clicking "+ Add new profile" from the main Overview page in Google Analytics
(google.com/analytics).
Select "new domain" in the wizard, and choose a descriptive but fake URL for
your app. The Web Property/Account ID will take the form "UA-0000000-1".


You must indicate to your users, either in the application itself or in your
terms of service, that you reserve the right to anonymously track and report a
user's activity inside of your app.


Referrer Tracking:


The SDK can track referrer information included when users follow links to your
application in Market.


To enable referrer tracking, a Broadcast Receiver needs to be registered in
your AndroidManifest.xml:


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



To pass referrer information to your application, link to it in Market as
follows:


http://market.android.com/search?q=pname:<package>&referrer=<referral>


where <package> is the application's package name, and <referral> is a url
encoded list of Analytics Campaign information. To construct these URLs, use
our URL builder:


http://code.google.com/apis/analytics/docs/tracking/mobileAppsTrackingAndroid.html


All tracked page views/events will be now be attributed to this campaign.


(NOTE: do not start the GoogleAnalyticsTracker in your Application onCreate()
method if using referral tracking).


Implementation Details:


Pageviews and events are stored in an SQLite database and dispatched to the
Google Analytics servers periodically, at a rate determined by the developer,
or manually.
A battery efficient strategy may be to "piggy-back" a dispatch just after the
application needs to perform network activity.
Dispatching happens by pipelining HTTP requests down a single connection
(one request per pageview/event with a maximum of 30 per dispatch).


Caveats:


Google Analytics currently does not honor timestamp information and hence
the time (day) of dispatch of the pageview/event is used instead.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值