Tag: google analytics api

在我的Rails应用中包含Google Analytics嵌入API第三方信息中心示例javascript

我在这里关注Google Analytics嵌入API这个例子,通过我的应用程序中的Chart.js实现GA第三方仪表板,我在Step 3遇到麻烦,我们将包括所有的javascript库。 我能够在我的application.js加载Embed API (function(w,d,s,g,js,fs){ g=w.gapi||(w.gapi={});g.analytics={q:[],ready:function(f){this.q.push(f);}}; js=d.createElement(s);fs=d.getElementsByTagName(s)[0]; js.src=’https://apis.google.com/js/platform.js’; fs.parentNode.insertBefore(js,fs);js.onload=function(){g.load(‘analytics’);}; }(window,document,’script’)); //= require /public/javascript/Chart.min.j //= require /public/javascript/moment.min.js //= require /public/javascript/embed-api/date-range-selector.js //= require /public/javascript/embed-api/active-users.js 它在开发工具的Networks部分显示cb=gapi.loaded_0正在加载。 但是,其他库不是。 Charts.min.js和Charts.min.js可在线获取,但我不确定在哪里可以找到embed-api/date-range-selector.js或者embed-api/active-users.js来检索到我的应用程序? EDIT1在这里找到文件: https : //github.com/googleanalytics/ga-dev-tools

客户端未经授权使用此方法检索访问令牌

我在Ruby on Rails项目中有一个自定义仪表板,其中包含从Google Analytics收集的数据。 我使用Google Analytics Reporting V4 API和服务帐户进行身份validation。 如果我没有模仿用户authorization.sub = ‘xxx@mail.com’ ,我的代码运行良好。如果我这样做,我会收到unauthorized_client错误,但不是所有时间。 有时它有效,有时不行。 这是我的代码: scope = [Google::Apis::AnalyticsreportingV4::AUTH_ANALYTICS_READONLY] view_id = ‘xxxxxx’ ENV[‘GOOGLE_APPLICATION_CREDENTIALS’] = “#{Rails.root}/private/google_analytics_key.json” authorization = Google::Auth::get_application_default(scope) authorization.sub = ‘xxx@mail.com’ analytics = Google::Apis::AnalyticsreportingV4::AnalyticsReportingService.new analytics.authorization = authorization … request = Google::Apis::AnalyticsreportingV4::GetReportsRequest.new(report_requests: report_requests) @result = analytics.batch_get_reports(request) Rails服务器日志输出: Sending HTTP post https://analyticsreporting.googleapis.com/v4/reports:batchGet? Caught error Authorization failed. Server message: […]