- 浏览: 539185 次
- 性别:
- 来自: 深圳
-
文章分类
最新评论
-
gaolegao2008:
如果报 is_volum 列名找不到之类的,我是从新部署了一个 ...
spring quartz 定时器报错 -
gaolegao2008:
部署到linux上时,还有一种情况就是mysql数据库区分大小 ...
spring quartz 定时器报错 -
qq123zhz:
yahier 写道 对我有帮助,但我看的一个demo程序,却没 ...
spring quartz 定时器报错 -
qq123zhz:
这个要在eclipse的插件环境下运行的,你不懂eclipse ...
GEF 自动布局 -
qq123zhz:
这个很久了,不记得啥时候写的了
json转为Map
google Analytics 是google的网站分析的工具,分析的很详细,google本身提供一套展示框架。
当然,我们可以自己制作客户端去连接google的服务器,然后取得我们所需要的数据,网上流传有flex air版的google analytics客户端,我下了一个,好像不能用,很多链接也打不开。
看到google 提供analytics的java支持,本来想看看有没flex 的。就玩了一下下。。。
主程序:
/* Copyright (c) 2008 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import com.google.gdata.client.analytics.AnalyticsService; import com.google.gdata.client.analytics.DataQuery; import util.SimpleCommandLineParser; import com.google.gdata.data.analytics.AccountEntry; import com.google.gdata.data.analytics.AccountFeed; import com.google.gdata.data.analytics.DataEntry; import com.google.gdata.data.analytics.DataFeed; import com.google.gdata.util.ServiceException; import java.io.IOException; import java.net.URL; import java.net.MalformedURLException; /** * Demonstrates how to use the Google Data API's Java client library to access * Google Analytics data. * * */ public class AnalyticsClient { private AnalyticsClient() {} public static final String ACCOUNTS_URL = "https://www.google.com/analytics/feeds/accounts/default"; public static final String DATA_URL = "https://www.google.com/analytics/feeds/data"; /** * Returns a data feed containing the accounts that the user logged in to the * given AnalyticsService has access to. * * @param myService The AnalyticsService to request accounts from * @return An AccountFeed containing an entry for each profile the logged-in * user has access to * @throws IOException If an error occurs while trying to communicate with * the Analytics server * @throws ServiceException If the API cannot fulfill the user request for * any reason */ public static AccountFeed getAvailableAccounts(AnalyticsService myService) throws IOException, ServiceException { URL feedUrl = new URL(ACCOUNTS_URL); return myService.getFeed(feedUrl, AccountFeed.class); } /** * Displays the accounts in the given account feed. */ public static void printAccounts(AccountFeed accountFeed) { System.out.println(accountFeed.getTitle().getPlainText()); for (AccountEntry entry : accountFeed.getEntries()) { System.out.println( "\t" + entry.getTitle().getPlainText() + ": " + entry.getTableId().getValue()); } System.out.println(); } /** * Gets a very basic data query request for the given table. * * @param tableId The ID of the table to request data from * @return A basic query for browser, visits, and bounce information from * the given table * @throws MalformedURLException If the URL used to request data is malformed */ public static DataQuery getBasicQuery(String tableId) throws MalformedURLException { // Set up the request (we could alternately construct a URL manually with all query parameters // set) DataQuery query = new DataQuery(new URL(DATA_URL)); query.setIds(tableId); query.setStartDate("2010-01-01"); query.setEndDate("2010-10-31"); query.setDimensions("ga:browser"); query.setMetrics("ga:visits,ga:bounces"); return query; } /** * Prints the contents of a data feed. * * @param title A header to print before the results * @param dataFeed The data feed containing data to print. Assumed to contain * ga:browser, ga:visits, and ga:bounces information. */ public static void printData(String title, DataFeed dataFeed) { System.out.println(title); for (DataEntry entry : dataFeed.getEntries()) { System.out.println("\tBrowser: " + entry.stringValueOf("ga:browser")); System.out.println("\t\tVisits: " + entry.stringValueOf("ga:visits")); System.out.println("\t\tBounces: " + entry.stringValueOf("ga:bounces")); System.out.println("\t\tBounce rate: " + entry.longValueOf("ga:bounces") / (double) entry.longValueOf("ga:visits")); } System.out.println(); } /** * Runs through all the examples using the given GoogleService instance. * * @param myService An unauthenticated AnalyticsService object * @throws ServiceException If the service is unable to handle the request * @throws IOException If there is an error communicating with the server */ public static void run(AnalyticsService myService, String username, String password) throws ServiceException, IOException { // Authenticate using ClientLogin myService.setUserCredentials(username, password); // Print a list of all accessible accounts AccountFeed accountFeed = getAvailableAccounts(myService); printAccounts(accountFeed); if (accountFeed.getEntries().isEmpty()) { return; } // Each entry in the account feed represents an individual profile AccountEntry profile = accountFeed.getEntries().get(0); String tableId = profile.getTableId().getValue(); // Print the results of a basic request DataQuery basicQuery = getBasicQuery(tableId); DataFeed basicData = myService.getFeed(basicQuery, DataFeed.class); printData("BASIC RESULTS", basicData); // Ask Analytics to return the data sorted in descending order of visits DataQuery sortedQuery = getBasicQuery(tableId); sortedQuery.setSort("-ga:visits"); DataFeed sortedData = myService.getFeed(sortedQuery, DataFeed.class); printData("SORTED RESULTS", sortedData); // Ask Analytics to filter out browsers that contain the word "Explorer" DataQuery filteredQuery = getBasicQuery(tableId); filteredQuery.setFilters("ga:browser!@Explorer"); DataFeed filteredData = myService.getFeed(filteredQuery, DataFeed.class); printData("FILTERED RESULTS", filteredData); // Ask Analytics to filter out browsers that contain the word "Explorer" DataQuery regionQuery = getBasicQuery(tableId); filteredQuery.setFilters("ga:region!@China"); DataFeed regionData = myService.getFeed(regionQuery, DataFeed.class); printData("REGION RESULTS", regionData); } /** * Uses the command line arguments to authenticate the GoogleService and build * the basic feed URI, then invokes all the other methods to demonstrate how * to interface with the Analytics service. * * @param args See the usage method. */ public static void main(String[] args) { String[] str1=new String[2]; str1[0]="--user=qq123zhz"; str1[1]="--pwd=112343"; // Set username, password and feed URI from command-line arguments. SimpleCommandLineParser parser = new SimpleCommandLineParser(str1); String userName = parser.getValue("username", "user", "u"); String userPassword = parser.getValue("password", "pwd", "p"); boolean help = parser.containsKey("help", "h"); if (help || (userName == null)) { usage(); System.exit(1); } AnalyticsService myService = new AnalyticsService("exampleCo-exampleApp-1"); try { run(myService, userName, userPassword); } catch (ServiceException se) { se.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } } /** * Prints the command line usage of this sample application. */ private static void usage() { System.err.println("Usage: AnalyticsClient --username <username> --password <password>"); System.err.println(); System.err.println("Fetches and displays various pieces of " + "information from the Google Analytics " + "Data Export API."); } }
ACCOUNTS_URL = "https://www.google.com/analytics/feeds/accounts/default";
DATA_URL = "https://www.google.com/analytics/feeds/data";
这两个地址分别是账号验证和ga数据存储的位置。
str1[0] = "--user=qq123zhz";
str1[1] = "--pwd=112343";
分别是用户名和密码,自己输入自己的google analytics帐户和密码,以上的密码被我改过了。
query.setStartDate("2010-01-01");
query.setEndDate("2010-10-31");
query.setDimensions("ga:browser");
query.setMetrics("ga:visits,ga:bounces");
设置查询的一些参数,起始结束时间,浏览器种类,查询访问量,还有一些其他的参数。。。
- google_analytics.rar (3.2 MB)
- 下载次数: 113
评论
2 楼
qq123zhz
2011-08-19
xuzhoudeliujin 写道
下载了,不知道好使不好使
还可以。。。
1 楼
xuzhoudeliujin
2011-08-17
下载了,不知道好使不好使
发表评论
-
eclipse Resource 资料
2016-11-15 16:51 638IWorkspace/IWorkspaceRoot/IPro ... -
.docker/machine/machines/default/ca.pem: no such file or directory
2016-09-06 15:59 911Was doing adocker-machine env ... -
list.AddAll 去重复
2015-09-11 12:01 5949问题描述: 有List A和B,A、B中元素都是可保证 ... -
eclipse 插件开发 Setting the Java build path
2014-06-04 11:00 1232JDT Plug-in Developer Guide & ... -
xstream 下划线_问题
2013-12-30 10:18 4203最近在使用xtream 1.4.3,出现了如下的问题: ... -
RCP MessageConsole设置显示的最大行数
2013-09-05 11:34 1009MessageConsole.setWaterMarks(5 ... -
freemarker 自定义freeMarker标签
2013-08-12 16:09 3900import java.io.IOException; i ... -
xstream javabean设置属性默认值的问题
2013-04-24 09:54 6584在xstream反序列化使用过程中发现,如果xml无该属 ... -
在使用xstream反序列化时遇到的问题
2013-04-24 09:42 1763public abstract class SBase { ... -
RCP 知识点
2013-03-14 15:10 1031获得工作区的所有工程: //获得workspace的所有 ... -
RCP FileSystem 文件系统
2013-02-19 10:42 1396public static File toLocalFile ... -
json转为Map
2013-01-19 22:27 32861package digu.pendant.util; ... -
eclipse4.x 去掉quick access
2013-01-11 14:57 4085/** * 去掉quick access * ... -
xstream 的高级用法,自定义输出结构
2012-12-19 14:35 2446public static void main(Stri ... -
jdt 核心知识
2012-11-27 21:39 1319jdt官方核心知识...................... ... -
jdt 创建java工程,生成代码,运行main方法
2012-11-27 10:50 2384public static IJavaProje ... -
两个osgi的例子程序
2012-11-20 10:21 1126osgi的例子....................直接上代 ... -
jfreechart 的官方例子,很全
2012-11-20 10:19 960jfreechart的官方的demon,很全。 -
SWT 隔行换色-自动宽高调整
2012-10-16 17:32 1729** * 创建:ZhengXi 2009-8-4 */ ... -
RCP 为action添加操作进度条
2012-10-16 13:59 1319public class StartAction extend ...
相关推荐
这一步会给你一个API密钥和OAuth 2.0客户端ID,它们是Java应用连接到Google Analytics API的关键。 接着,确保你已经安装了Google的Java Client Library for Google Analytics Data API。这个库简化了与API的交互...
跟踪ID是连接我们应用和Google Analytics服务器的关键,每个应用都应该有唯一的ID。在Android Studio项目中,我们需要添加Google Play Services库,因为Google Analytics服务包含在这个库中。这可以通过修改`build....
Google Analytics JAR文件是这个服务的一部分,通常是一个包含Java类库的压缩包,用于帮助开发者在自己的Java应用中集成Google Analytics功能。 首先,`ga_lib`目录很可能是包含了Google Analytics的Java库文件,...
3. 获取网络载体 ID:在创建成功后,会得到一个唯一的网络载体 ID(UA-XXXXX-YY),它连接你的应用程序到 Google Analytics 帐户的配置文件。这个 ID 是追踪数据的关键,包括帐户编号和配置文件编号。 开始使用 SDK...
Google Analytics 是一款强大的数据分析工具,由谷歌提供,用于追踪和分析网站以及移动应用的流量数据。在 Android 应用程序中集成 Google Analytics,开发者可以深入了解用户行为,优化应用性能,提高用户体验。 *...
在Google Analytics API的上下文中,2legged OAuth被用来让应用直接代表用户获取数据,而无需用户手动进行登录或授权流程。 在使用2legged OAuth与Google Analytics API交互时,通常涉及以下几个步骤: 1. **注册...
这些JAR库包含了一系列预先编译的类和方法,使得开发者能够轻松地与Google的各种API进行交互,如Google Maps、Google Drive、Google Calendar、Google Analytics等。本文将深入探讨Google API的JAR文件,以及如何在...
8. **分析与监控**:为了了解应用的实际运行情况,可能会集成各种分析和监控工具,如Google Analytics、Crashlytics等,以便收集性能数据,及时发现并解决问题。 9. **编译构建优化**:使用Gradle作为构建工具,...
1. Google Analytics Java库:Google提供了官方的Measurement Protocol库,使得开发者能够通过Java代码发送数据到Google Analytics。例如,你可以使用HttpURLConnection或者HttpClient发送POST请求。 2. 使用 ...
【Java_课程代码库Firebase在一个周末由谷歌Android.zip】是一个包含与使用Firebase集成到Android应用相关的教学资源的压缩包。Firebase是由谷歌提供的一款全面的后端服务平台,它为开发者提供了实时数据库、身份...
2. **Google Analytics或其他第三方工具**:“myOnlinesWeb”也可能集成Google Analytics或其他第三方统计工具,以获取更详细的访问数据,如用户来源、设备类型、跳出率等。 3. **数据库存储**:访问量数据通常会...
通过9.2.0版本的SDK,开发者可以轻松地在Android应用中实现数据的实时更新和同步,无论用户在网络连接不稳定或者离线的情况下都能保证数据的一致性。 Firebase身份验证服务是另一个重要的组成部分,它支持多种身份...
这样做是为了我可以在 java gui 应用程序上使用谷歌出色的分析软件,因为谷歌从未制作过用于发送跟踪数据的 java 实现。 目前该库支持页面查看跟踪(可以有来自页面或搜索引擎的引用)和事件跟踪。 有关基本设置,...
"GA" 可能代表“Google Analytics”或其他相关缩写,暗示这个项目可能涉及到网站或应用的数据追踪。 【描述】"GAEmptyDataDemo" 描述非常简洁,可能意味着这是一个展示如何处理“暂无数据”和“暂无网络”情况的...
还可以集成第三方统计服务(如Google Analytics),以获取更丰富的用户行为数据。 通过以上步骤,我们可以构建一个基本的JSP流量统计系统,它可以实时收集和分析网站的访问数据,为网站运营提供有力支持。然而,...
【GADS实践项目】是一个基于Java技术的综合实践项目,旨在帮助学习者深入理解和应用GADS(Google Analytics Data Studio)相关的数据处理与分析技能。在这个项目中,你将有机会运用Java编程语言,结合数据分析工具,...
还可以使用Google Analytics或其他第三方服务,通过JavaScript代码嵌入到网页中收集数据,提供更详细的用户行为分析。 5. **管理员权限控制** 管理员踢出用户功能涉及到权限管理。项目可能采用了角色-权限模型,...
9. **数据分析**:利用Google Analytics或其他分析工具监控网站流量,了解用户行为,持续优化网站性能。 10. **社交媒体整合**:将企业站点与微信、微博等社交平台连接,扩大影响力,提高用户参与度。 此外,"另类...