标签: google-analytics-api

(403)您的项目无权访问此功能

按照有关如何插入webproperties的文档,以便我可以动态创建跟踪代码.目标是在Google Analytics中移动我们的分析,并在分析下自动在自己的Google帐户中创建客户网站.在我在网上找到的小东西之后,似乎这个功能可能被列入白名单.所以我正在提出这个问题来弄清楚天气是否如此.文档很难弄清楚,因为它没有告诉你需要哪些字段,字段意味着什么等.似乎文档已经过时的PHP库.不得不改变很多示例代码类名称和方法名称以使其"正常工作".

这是我用来测试此功能的代码片段.

<?php
require_once 'Google/Client.php';
require_once 'Google/Service/Analytics.php';
require_once 'Google/Service/Oauth2.php';

session_start();

$client = new Google_Client();

$client->setClientId('xxxxx');
$client->setClientSecret('xxxxxx');
$client->setRedirectUri('xxxxxxxx');
$client->setDeveloperKey('xxxxxxx');
$client->setScopes(
    array(
          'https://www.googleapis.com/auth/analytics.readonly',
          'https://www.googleapis.com/auth/analytics',
          'https://www.googleapis.com/auth/userinfo.profile',
          'https://www.googleapis.com/auth/analytics.edit',
          'https://www.googleapis.com/auth/analytics.manage.users'
    )
);

$oauth2 = new Google_Service_Oauth2($client);

if (isset($_GET['code'])) {
  $client->authenticate($_GET['code']);
  $_SESSION['access_token'] = $client->getAccessToken();
  $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
  header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
}

if (isset($_REQUEST['logout'])) {
  unset($_SESSION['access_token']);
}

if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
  $client->setAccessToken($_SESSION['access_token']);
}

if (!$client->getAccessToken()) {
  $authUrl = $client->createAuthUrl();

  print "<a class='login' href='$authUrl'>Connect Me!</a>";

} else {
    $analytics = …
Run Code Online (Sandbox Code Playgroud)

php google-analytics google-api google-analytics-api google-api-php-client

3
推荐指数
1
解决办法
1020
查看次数

Google Analytics嵌入式API身份验证

我正在尝试使用嵌入式API从Google Analytics中获取一些统计信息,以便使用javascript在我们的网站上显示.

我的问题是:

是否可以在没有用户身份验证的情况下显示统计信息?即我想为匿名用户提供一些流量统计信息.

谢谢,克里斯.

google-analytics google-analytics-api

3
推荐指数
1
解决办法
4733
查看次数

嵌入API第三方可视化Google分析

我正在尝试使用第三方供应商的API绘制Google Analytics图表以显示在我自己的信息中心上.我的代码有效,但是我注册了几个网页,除非我手动更改(调用字段PROPERTY),否则它总是显示相同的默认值.我想要一个不同的默认网络.

我试图隐藏视图选择器并直接放入ID(ga:'xxxx'),如果将其放入图表执行中,则可以正常工作:

   renderWeekOverWeekChart('ga:123456');
Run Code Online (Sandbox Code Playgroud)

它工作正常,向我展示我想要的正确图表.

如何显示活跃用户?我不知道在哪里可以为它定义id值.

这是我的代码(我已将客户ID更改为'XXX')

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ift.tt/kkyg93">
<html xmlns="http://ift.tt/lH0Osb">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Thirtd Party Visualizations</title>
<link rel="stylesheet" href="https://ga-dev-tools.appspot.com/public/css/main.css" />
<script>
(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'));
</script>
</head>
<body>

<div id="embed-api-auth-container"></div>
<div id="view-selector-container"></div>
<div id="active-users-container"></div>
<h3 id="view-name"></h3>
<style>
  div[id^="chart"] {
    width: 500px;
    height: 300px;
  }
</style>

<div id="chart-1-container"></div>
<div id="legend-1-container"></div>
<div id="chart-2-container"></div>
<div id="legend-2-container"></div>
<div id="chart-3-container"></div>
<div id="legend-3-container"></div>
<div id="chart-4-container"></div>
<div id="legend-4-container"></div>
</body>
<script src="https://ga-dev-tools.appspot.com/public/javascript/moment.min.js"></script>
<script src="https://ga-dev-tools.appspot.com/public/javascript/Chart.min.js"></script> …
Run Code Online (Sandbox Code Playgroud)

javascript google-analytics google-analytics-api

3
推荐指数
1
解决办法
2124
查看次数

实时显示 Google Analytics 数据

我想显示自本月初以来网站上的访问者数量、当天和当前在网站上的用户数量。

我安装了 Google Analytics,我尝试通过从开发人员控制台启用 Google Analytics API 来使用嵌入 API 来解决此问题 - 但我需要用户授权等。

在没有用户身份验证和接受嵌入式 API 等访问的情况下现场显示分析的最简单方法是什么。应用程序是用 Angular 编写的,因此 Javascript API 是我寻找的。

感谢您的任何建议。

google-analytics google-analytics-api angularjs

3
推荐指数
1
解决办法
3120
查看次数

仅使用 API 密钥访问 Google Analytics 数据

我正在尝试在 Javascript 中使用 Google Analytics API。我想要:

  • 查询特定网站的数据(在我的控制下)
  • 使用数据构建一个向公众开放的仪表板

我能找到的每个示例都要求您在查询数据之前使用 OAuth 进行身份验证。因为我只是想查询(而不是删除/修改),是有办法使用一个简单的API密钥来获取数据,我需要一种方式?

javascript google-analytics-api google-analytics-firebase google-analytics-sdk

3
推荐指数
1
解决办法
3312
查看次数

如何在测量协议中发送批量请求

我正在为我的桌面应用程序使用测量协议。

使用以下 URL,我可以向 Google Analytics(GA)发送单个请求。

https://www.google-analytics.com/collect?v=1&tid=UA-XXXXXX-1&cid=754654B98786B&t=event&ec=Test&ea=click&cd=XYZ&an=XYZ&aid=123&av=3.0&aiid=1.0
Run Code Online (Sandbox Code Playgroud)

但我想向 GA 发送多个请求。根据文档,使用 /batch 我们可以发送多个请求。

我试过这个网址,

https://www.google-analytics.com/batch?
v=1&tid=UA-XXXXXX-1&cid=754654B98786B&t=event&ec=Test1&ea=click&cd=XYZ&an=XYZ&aid=123&av=3.0&aiid=1.0
&v=1&tid=UA-XXXXXX-1&cid=754654B98786B&t=event&ec=Test2&ea=click&cd=XYZ&an=XYZ&aid=123&av=3.0&aiid=1.0
&v=1&tid=UA-XXXXXX-1&cid=754654B98786B&t=event&ec=Test3&ea=click&cd=XYZ&an=XYZ&aid=123&av=3.0&aiid=1.0
Run Code Online (Sandbox Code Playgroud)

但在报告中只记录了第三个事件。

请帮我解决这个问题。

google-analytics google-analytics-api measurement-protocol

3
推荐指数
1
解决办法
4091
查看次数

将过滤器与 Google Analytics 报告 API 结合使用

以下代码应该能够按 EXACT eventCategory 进行过滤,但它不起作用。它返回所有可用的事件,当然它有点混乱。

/*

  this querystring is what I'd like to receive, I've built it with the query explorer: https://ga-dev-tools.appspot.com/query-explorer/
  ids=ga:private&
  start-date=2017-05-01&
  end-date=yesterday&
  metrics=ga:eventValue,ga:avgEventValue&
  dimensions=ga:subContinent,ga:eventCategory,ga:eventAction,ga:eventLabel&
  filters=ga:eventCategory==video
*/

// Create the DateRange object.
$dateRange = new Google_Service_AnalyticsReporting_DateRange();
$dateRange->setStartDate("3daysago");
$dateRange->setEndDate("today");


// Create the Metrics object.
$ev = new Google_Service_AnalyticsReporting_Metric();
$ev->setExpression("ga:eventValue");
$ev->setAlias("EventValue");

$avg = new Google_Service_AnalyticsReporting_Metric();
$avg->setExpression("ga:avgEventValue");
$avg->setAlias("Avg Value");

//Create the dimensions
$sc = new Google_Service_AnalyticsReporting_Dimension();
$sc->setName("ga:subContinent");

$ec = new Google_Service_AnalyticsReporting_Dimension();
$ec->setName("ga:eventCategory");

$ea = new Google_Service_AnalyticsReporting_Dimension();
$ea->setName("ga:eventAction");

$el = new Google_Service_AnalyticsReporting_Dimension();
$el->setName("ga:eventLabel"); …
Run Code Online (Sandbox Code Playgroud)

php google-api google-analytics-api google-api-php-client

3
推荐指数
1
解决办法
1896
查看次数

如何使用谷歌分析 API 在谷歌分析中访问用户资源管理器数据

我想使用 Google 分析 API 访问用户资源管理器数据以获取 JSON 值形式的报告。使用此 JSON 值,我可以创建用于分析的 Web 应用程序仪表板。我在此链接中找不到任何指标和维度来获取用户资源管理器的详细信息

请分享是否有任何相关文件或任何使用 Google 分析 API 访问用户资源管理器数据的链接

google-analytics google-analytics-api

3
推荐指数
1
解决办法
4265
查看次数

尝试访问谷歌分析时指定的提供程序类型无效

每当我们尝试访问 API 以获取当前用户编号时,我们都会收到以下错误。我已经尝试了几件事,但无法深入了解这一点。任何人都可以阐明什么是错误/缺失的吗?

我应该指出,因此在我的本地 PC 上运行得非常好,但在服务器上却失败了。

这是错误:

ConnectToAnalytics 错误:System.Security.Cryptography.CryptographicException:指定的提供程序类型无效。在 System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer) at System.Security.Cryptography.Utils.GetKeyPairHelper(CspAlgorithmType keyType, CspParameters 参数, Boolean randomKeyContainer, Int32 dwKeySize, SafeProvHandle& safeProvHandle, SafeKeyHandle System.safeKeyHandle) .Cryptography.RSACryptoServiceProvider.GetKeyPair() at System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 dwKeySize, CspParameters parameters, Boolean useDefaultKeySize) at System.Security.Cryptography.X509Certificates.X509Certificate2.get_PrivateKey() at Google.Apis. OAuth2.ServiceAccountCredential.Initializer。

当我运行代码时抛出此错误:

Public Shared Function GetRealtimeUsers() As String
    Try
        'realtime on site
        Dim gsService As AnalyticsService = Core.ConnectToAnalytics
        Dim RequestRealtime As DataResource.RealtimeResource.GetRequest = gsService.Data.Realtime.[Get]([String].Format("ga:{0}", "xxxxx"), "rt:activeUsers")
        Dim feed As RealtimeData = RequestRealtime.Execute()

        Return Int(feed.Rows(0)(0)).ToString()
    Catch ex As Exception
        Return "QUOTA USED"
    End …
Run Code Online (Sandbox Code Playgroud)

asp.net google-api google-analytics-api google-api-dotnet-client service-accounts

3
推荐指数
1
解决办法
1568
查看次数

Guzzle Error count(): 参数必须是一个数组或一个在

我正在关注下面的文章, https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/web-php

但是最后,当我尝试使用示例代码(HelloAnalytics.php)时,它会在命令行中显示如下错误并且无法获取数据;

PHP 警告:count(): Parameter must be an array or an object that implementation Countable in C:\xampp\htdocs\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 67

警告:count(): Parameter must be an array or an object that implementation Countable in C:\xampp\htdocs\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 67 PHP Warning: count(): Parameter must是第 67 行 C:\xampp\htdocs\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php 中实现 Countable 的数组或对象

警告:count():参数必须是在 C:\xampp\htdocs\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php 中实现 Countable 的数组或对象,第 67 行 PHP 致命错误:未捕获的 Google_Service_Exception:{" error":{"errors":[{"domain":"usageLimits","re​​ason":"accessNotConfigured","message":"Project 687417168367 未找到且不能用于 API 调用。如果它是最近创建的,通过访问https://console.developers.google.com/apis/api/analytics.googleapis.com/overview?project=687417168367启用 Google Analytics API,然后重试。如果您最近启用了此 API,请等待几分钟以进行操作传播到我们的系统并重试。","extendedHelp":" https://console.developers.google。com/apis/api/analytics.googleapis.com/overview?project=687417168367"}],"code":403,"message":"项目 687417168367 未找到,无法用于 API 调用。如果它是最近创建的,请访问https://console.developers.google.com/apis/api/analytics.googleapis.com/overview?project=687417168367启用 Google Analytics …

php google-api google-analytics-api google-api-php-client

3
推荐指数
2
解决办法
6205
查看次数