用于.NET的Google API客户端库(google-api-dotnet-client)和用于Google Analytics API 的Google数据API(google-gdata)的.NET库有何区别?
我通过服务帐户查询Analytics API .
我已经在开发服务器上编写了代码,它没有问题.在生产服务器上运行相同的代码时,它会抛出:
Google_AuthException:刷新OAuth2令牌时出错,消息:'{"error":"invalid_grant"}'
我尝试过创建另一个服务帐户,行为是一样的.
oAuth IETF草案(http://tools.ietf.org/html/draft-ietf-oauth-v2-31)对此错误说:
invalid_grant
The provided authorization grant (e.g. authorization
code, resource owner credentials) or refresh token is
invalid, expired, revoked, does not match the redirection
URI used in the authorization request, or was issued to
another client.
Run Code Online (Sandbox Code Playgroud)
这是我写的代码:
$GA_CLIENT_ID = 'XX.apps.googleusercontent.com';
$GA_APP_EMAIL = 'XX@developer.gserviceaccount.com';
$GA_APP_NAME = 'XX';
$GA_KEY_FILE = 'XX';
// create client object and set app name
$client = new Google_Client();
$client->setApplicationName($GA_APP_NAME); // name of your app
// set …Run Code Online (Sandbox Code Playgroud) 我正在构建一个应用程序,允许管理员验证对其分析帐户的访问权限以供脱机使用,并将刷新令牌存储在数据库中.
现在,当我尝试在前端使用API时,它返回以下错误:
"Access Token Expired. There wan a general error : The OAuth 2.0 access token has expired, and a refresh token is not available. Refresh tokens are not returned for responses that were auto-approved."
Run Code Online (Sandbox Code Playgroud)
这是我到目前为止生成此错误的代码:
require_once "lib/google/Google_Client.php";
require_once "lib/google/contrib/Google_AnalyticsService.php";
$_analytics = new analytics();
$_googleClient = new Google_Client();
$_googleClient->setClientId($_analytics->gaClientId);
$_googleClient->setClientSecret($_analytics->gaClientSecret);
$_googleClient->setRedirectUri($_analytics->gaRedirectUri);
$_googleClient->setScopes($_analytics->gaScope);
$_googleClient->setAccessType($_analytics->gaAccessType);
// Returns last access token from the database (this works)
$_tokenArray['access_token'] = $_analytics->dbAccessToken($_agencyId);
$_googleClient->setAccessToken(json_encode($_tokenArray));
if($_googleClient->isAccessTokenExpired()) {
// Don't think this is required for Analytics API V3
//$_googleClient->refreshToken($_analytics->dbRefreshToken($_agencyId)); …Run Code Online (Sandbox Code Playgroud) 我正在使用PHP访问Google分析API,这可以在我的最终使用,但我希望能够进一步过滤结果.现在我正在使用:
$OBJresult = $analytics -> data_ga -> get(
'ga:' . $profilID,
'2012-01-01',
date( "Y-m-d" ),
'ga:visits',
array(
'dimensions' => 'ga:pagePath',
'metrics' => 'ga:pageviews',
'sort' => '-ga:pageviews',
'max-results' => '25'
)
);
Run Code Online (Sandbox Code Playgroud)
目前,这将返回按其命中排序的25页.我希望将结果限制在服务器内的特定路径.因此,例如,仅查询domain.com/news,并且仅查看最受欢迎的新闻页面.我可以使用PHP过滤,而是尽可能具体地查询.
谢谢您的帮助
自定义指标/维度和事件之间有什么区别?
据我所知,基本的区别是:
我学会了先使用事件.我的代码中有以下事件(类别/操作):
Account / create
Transaction / create / <transaction type>
Transaction / create-first (the first time the user interacts with the app)
Transaction / remove
Run Code Online (Sandbox Code Playgroud)
以下针对这些事件的目标:
Create account -> Account/create
Create the first transaction (Transaction/create-first)
Run Code Online (Sandbox Code Playgroud)
我可以使用配置为显示Total events,按事件操作和类别过滤的度量窗口小部件或直接显示目标来查看报告中的这些数据,因为它们是度量标准.
但后来我发现了自定义指标,现在我不知道应该使用哪一个跟踪这些数据.虽然事件似乎更灵活,但我可以用两者获得相同的结果.使用自定义指标和维度,我可以进行以下配置:
度量
Total transactions
Created accounts
Removed transactions
Run Code Online (Sandbox Code Playgroud)
外形尺寸
Transaction type
Run Code Online (Sandbox Code Playgroud)
我弄错了吗?两者都解决了这个问题,但我相信现在选择合适的问题可能会让我免于未来的问题.
我已经成功配置了google analytics api并获得了成功的数据.
我想在没有gmail登录的情况下访问analytics api.
即我将硬编码凭据登录,但如何用PHP做?
是否有任何api函数来执行此任务(对于PHP)
谢谢!
google-analytics google-api google-analytics-api google-api-php-client
我正在尝试运行此处提供的示例https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/service-py进行授权.
我从SO中的其他问题中注意到(ImportError:无法导入名称SignedJwtAssertionCredentials)SignedJwtAssertionCredentials已被删除,因此无法导入.
因此,我开始遵循GitHub页面(https://github.com/google/oauth2client/issues/401)和StackOverflow 提供的解决方案.到目前为止,没有任何效果,我仍然看到同样的错误.以下是我的代码.
import argparse
from apiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials
import httplib2
from oauth2client import client
from oauth2client import file
from oauth2client import tools
Run Code Online (Sandbox Code Playgroud)
而且,这是我在运行上述代码时收到的错误.
ImportError: cannot import name ServiceAccountCredentials
Run Code Online (Sandbox Code Playgroud)
由于我是这个领域的全新手,我试着为OAuth(2.0.0和1.5.2)这两个版本做到这一点.我也在安装后尝试过pyopenssl,但仍然失败了.
python google-api google-analytics-api oauth-2.0 google-oauth
我已经实施了Firebase Analytics.它工作正常.我也希望使用Google Analytics.基于此处的讨论,我在google-services.json中包含了以下对象
"analytics_service": {
"status": 2,
"analytics_property": {
"tracking_id": "<your tracking id>"
}
},
Run Code Online (Sandbox Code Playgroud)
对于Google Analytics,我有跟踪器类
public class PuzzleGamesTracker extends Application {
// The following line should be changed to include the correct property id.
private static final String PROPERTY_ID = "<your tracking id>";
private Tracker mTracker;
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
/**
* Gets the default {@link Tracker} for this {@link Application}.
* @return tracker
*/
synchronized public Tracker getDefaultTracker() …Run Code Online (Sandbox Code Playgroud) android google-analytics google-analytics-api firebase firebase-analytics
当我直接通过 HTTPS 请求而不使用 Firebase 或 gtag.js 使用 GA4 测量协议时,Google Analytics(分析)不会显示任何用户信息,例如屏幕分辨率、位置、语言等,而我尝试通过 user_properties 或事件传递这些信息。也许我使用了错误的标签或错误的位置来传递这些变量?
我尝试使用 sr/screen_resolution、ul/location/country/geoid、language/lg、...
如何手动传递这些变量以及以哪种格式?Firebase 和 gtag 自动收集它们,但由于我不使用它们(也不建议使用它们),我想知道如何以正确的方式做到这一点。
google-analytics-api measurement-protocol google-analytics-4