GA追踪代码详解
来源:互联网 发布:淘宝卖家能知道买家 编辑:程序博客网 时间:2024/06/06 00:18
GA追踪代码详解
GA的作用就是获取你的应用程序的用户使用量,用户的点击行为,事件,地点等,还可以统计应用崩溃的详情等。
首先进入谷歌www.google.com/analytics/的GA网址,然后注册一个账号,里面会有android和ios的接入指南:
https://developers.google.com/analytics/devguides/collection/android/v3/
https://developers.google.com/analytics/devguides/collection/ios/v3/
下面的这个是使用的API:
https://developers.google.com/analytics/devguides/collection/android/v3/#manifest
按照里面的步骤一步一步来就行了。需要注意的一点就是每个activity都要配置API中的onstart和onstop方法。
还需要在API指引的地方下载一个libGoogleAnalyticsServices.jar,引入工程就可以了。
下面是API的具体内容:
Google Analytics SDK for Android v3 (Beta) - Getting Started
This document describes how to get started using the Google Analytics SDK for Android v3.
Migrating from v1 or v2? Check out our Migration Guide to get started using v3.
Before You BeginGetting Started 1. Updating AndroidManifest.xml 2. Adding EasyTracker methods 3. Creating your analytics.xml fileNext steps
Before you Begin
Before implementing the SDK, make sure you have the following:
Android developer SDK (available for Windows, Mac OS X, and Linux)Google Analytics SDK for Android v3 (with libGoogleAnalyticsServices.jar included in your project's /libs directory and build path)An Android app that you can use to implement the Google AnalyticsA new Google Analytics app property and view (profile).
Getting Started
There are three steps to getting started with the SDK:
Update AndroidManifest.xmlAdd EasyTracker methodsCreate your analytics.xml file
After completing these steps, you’ll be able to measure the following with Google Analytics:
App installationsActive users and demographicsScreens and user engagementCrashes and exceptions
- Updating AndroidManifest.xml
Update your AndroidManifest.xmle file by adding the following permissions:
- Adding EasyTracker methods
Add the send methods to the onStart() and onStop() methods of each of your Activities as in the following example:
package com.example.app;
import android.app.Activity;
import com.google.analytics.tracking.android.EasyTracker;
/**
* An example Activity using Google Analytics and EasyTracker.
*/
public class myTrackedActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public void onStart() {
super.onStart();
… // The rest of your onStart() code.
EasyTracker.getInstance(this).activityStart(this); // Add this method.
}
@Override
public void onStop() {
super.onStop();
… // The rest of your onStop() code.
EasyTracker.getInstance(this).activityStop(this); // Add this method.
}
}
- Creating your analytics.xml file
When you use EasyTracker, global configuration settings are managed using resources defined in XML. Create a file called analytics.xml in your project’sres/values directory and add the following resources:
- GA追踪代码详解
- GA追踪代码详解
- GA 跨域追踪
- VS通过MAP追踪异常代码的位置详解
- surfaceflinger 代码追踪
- surfaceflinger 代码追踪 .
- 代码追踪 20130419
- google 追踪代码
- YII 代码追踪
- java BTrace-代码追踪
- Eclipse代码追踪功能
- 页面添加GA代码,10个GA基础应用
- ga
- ga
- GA
- GA
- 使用Eclipse中的代码追踪
- Eclipse的代码追踪功能
- Vim 实用技术,第 2 部分: 常用插件
- Why does my NSDateFormatter sometimes return an a.m. or p.m. with yyyyMMddHHmmssSSS
- SSH学习四 Hibernate多对一的关系 + 增删改查
- SQL的四种连接-左外连接、右外连接、内连接、全连接
- GCD理解(三)
- GA追踪代码详解
- stdout 与 stderr区别
- CGRectInset、CGRectOffset详解
- MTK中加入ETT测试代码
- 当启动多个Activity后从最后一个activiy越级返回方法
- 分析android动画模块
- hdu5327 Olympiad(简单题:打表+模拟)
- 我的游戏开发笔记(二):加状态以及检东西
- eclipse中用struts2时报Path must include project and resource name: /struts-default.xml的错误