我可以使用Google Analytics(免费版)跟踪我的软件统计信息吗?或者我应该为使用这项服务付费吗?
答案 0 :(得分:3)
是的,您可以使用Measurement Protocol(测试版)将数据发送到Google Analytics。从您的软件发出HTTP POST或GET到下面的URL:
http://www.google-analytics.com/collect
请参阅Parameter Reference链接,了解您可以通过Measurement Protocol发送的参数列表。
Java中的示例代码:
HttpClientWrapper http = new HttpClientWrapper();
HttpParameter[] params = new HttpParameter[8];
params[0] = new HttpParameter("v", "1");
params[1] = new HttpParameter("tid", "UA-XXXX");
params[2] = new HttpParameter("cid", clientId);
params[3] = new HttpParameter("t", "appview");//hit type
params[4] = new HttpParameter("an", app);
params[5] = new HttpParameter("av", version);
params[6] = new HttpParameter("cn", campaignName);
params[7] = new HttpParameter("cd", screen);
HttpResponse response = http.post("http://www.google-analytics.com/collect",
params);
System.out.println("Response:" + response.asString());