这应该是非常简单的,但无论我尝试什么,我都无法工作.我正在尝试将Google Analytics与GWT应用程序结合使用.根据我的理解,有两种方法可以做到:
首先是同步,通过在<head>部分HTML页面的末尾插入跟踪代码,然后调用此方法:
public static native void recordAnalyticsHit(String pageName) /*-{
pageTracker._trackPageview(pageName);
}-*/;
Run Code Online (Sandbox Code Playgroud)
其次是异步,通过在<body>标签之后插入跟踪代码然后调用此方法:
public static native void recordAnalyticsHit(String pageName) /*-{
_gaq.push(['_trackPageview(' + pageName + ')']);
}-*/;
Run Code Online (Sandbox Code Playgroud)
但是,在运行这些方法时,我会在托管模式下获得此异常:
[ERROR] [myproject] Uncaught exception escaped
com.google.gwt.core.client.JavaScriptException: (ReferenceError): pageTracker is not defined
[ERROR] [myproject] Uncaught exception escaped
com.google.gwt.core.client.JavaScriptException: (ReferenceError): _gaq is not defined
Run Code Online (Sandbox Code Playgroud)
在观察Firebug中的网站时,我看到ga.js被加载了,但就是这样.
有没有人让Google Analytics与GWT合作?此外,_gaq是否接受页面名称作为trackPageview参数,因为我见过的所有示例都使用此调用:
_gaq.push(['_trackPageview()']);
Run Code Online (Sandbox Code Playgroud)
(当然,这对我也不起作用.)
我意识到这个问题之前已经被问过,但是代码示例的方式很少,所以我再问一次,但至少有一点方向.
经过几个小时的搜索,我得出了以下部分实现.
namespace GoogleAnalyticsAPITest.Console
{
using System.Security.Cryptography.X509Certificates;
using DotNetOpenAuth.OAuth2;
using Google.Apis.Analytics.v3;
using Google.Apis.Analytics.v3.Data;
using Google.Apis.Authentication.OAuth2;
using Google.Apis.Authentication.OAuth2.DotNetOpenAuth;
class Program
{
static void Main(string[] args)
{
log4net.Config.XmlConfigurator.Configure();
string Scope = Google.Apis.Analytics.v3.AnalyticsService.Scopes.Analytics.ToString().ToLower();
string scopeUrl = "https://www.googleapis.com/auth/" + Scope;
const string ServiceAccountId = "nnnnnnnnnnn.apps.googleusercontent.com";
const string ServiceAccountUser = "nnnnnnnnnnn@developer.gserviceaccount.com";
AssertionFlowClient client = new AssertionFlowClient(
GoogleAuthenticationServer.Description, new X509Certificate2(@"7039572692013fc5deada350904f55bad2588a2a-privatekey.p12", "notasecret", X509KeyStorageFlags.Exportable))
{
Scope = scopeUrl,
ServiceAccountId = ServiceAccountId//,ServiceAccountUser = ServiceAccountUser
};
IAuthorizationState state = AssertionFlowClient.GetState(client);
AnalyticsService service = new AnalyticsService(authenticator);
string profileId = "ga:xxxxxxxx";
string …Run Code Online (Sandbox Code Playgroud) 我使用Google Web Analytics在线工具来监控我网站上的访问.让我烦恼的是,我经常看到记录中包含以下条目:
页面访问量:1.00平均访问持续时间:00:00:00跳出率:100%
那是什么意思?如果访问者来到我的网站,它应该至少保持几秒钟,直到他离开?这可能意味着访问我的网站有问题(之前我遇到过类似的问题,但我确信我已修复它们,因为当我尝试从不同的计算机访问我的网站时,我没有收到任何错误.)
我正在使用SDK for Android V2.0 beta 3中的EasyTracker.我已按照https://developers.google.com/analytics/devguides/collection/android/v2/中描述的所有步骤操作,并确保了在我的ga_trackingId参数值中有连字符而不是短划线.
我已经在Android 2.2和4.1.2以及真实设备上的模拟器中尝试过我的应用程序.这是LogCat的(部分编辑)输出:
11-17 20:13:50.587: W/GAV2(542): Thread[main,5,main]: Connection to service failed 1
11-17 20:13:50.616: W/GAV2(542): Thread[main,5,main]: Need to call initialize() and be in fallback mode to start dispatch.
11-17 20:13:50.616: I/GAV2(542): Thread[main,5,main]: ExceptionReporter created, original handler is com.android.internal.os.RuntimeInit$UncaughtHandler
11-17 20:13:52.617: I/GAV2(542): Thread[GAThread,5,main]: No campaign data found.
11-17 20:13:52.646: I/GAV2(542): Thread[GAThread,5,main]: putHit called
11-17 20:13:55.606: I/GAV2(542): Thread[Service Reconnect,5,main]: connecting to Analytics service
11-17 20:13:55.616: I/GAV2(542): Thread[Service Reconnect,5,main]: connect: bindService returned false for Intent { …Run Code Online (Sandbox Code Playgroud) 是否可以使用官方Google API for C#发送"PageViews"并记录活动?例如,如果我想跟踪我的wpf/winforms桌面应用的页面浏览量.?
我在哪里可以找到一些正式的例子?
是谷歌API的Ruby客户的最佳选择?
我有一个网站example.com和用户,我希望他们在example.com上看到他们的谷歌分析统计数据,我该怎么办?
我可以看到这个例子,但我无法弄清楚如何开始.
google-analytics ruby-on-rails google-analytics-api ruby-on-rails-3
我正在尝试创建一个服务帐户应用,以便我可以使用Python访问Google Analytics API.有两件事令我困惑.首先,当我使用以下代码时:
`from oauth2client.client import SignedJwtAssertionCredentials
client_email = "#####client_email#######.gserviceaccount.com"
with open("XXXXXX.p12") as f:
private_key = f.read()
credentials = SignedJwtAssertionCredentials(client_email, private_key,'https://www.googleapis.com/auth/sqlservice.admin')`
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
`oauth2client.client.CryptoUnavailableError: No crypto library available`
Run Code Online (Sandbox Code Playgroud)
在做了一些研究之后,我发现这可能与将app域范围的权限授予服务帐户有关.但是,当我登录Google Developers Console时,无法找到安全图标或更多选项按钮.任何帮助非常感谢谢谢.
我知道Google Analytics没有官方API,但是有没有办法通过C#访问Google Analytics报告?
我正在研究谷歌测量协议,它为您提供了一种从服务器发送谷歌分析信息的方法.但是,似乎不需要任何身份验证.我错过了什么吗?否则,什么阻止其他人随意向我的帐户发送假数据?
以下代码返回一个对象 Google_Service_AnalyticsReporting_GetReportsResponse
$body = new Google_Service_AnalyticsReporting_GetReportsRequest();
$body->setReportRequests($aRequests);
return $this->oAnalytics->reports->batchGet($body);
Run Code Online (Sandbox Code Playgroud)
我想知道我是否可以以不同的格式获取报告,例如:
Array(Dimension,value)