我正在使用Google AnalyticsAPI,我按照这个SO问题来设置OAuth:https://stackoverflow.com/a/13013265/1299363
这是我的OAuth代码:
public void SetupOAuth ()
{
var Cert = new X509Certificate2(
PrivateKeyPath,
"notasecret",
X509KeyStorageFlags.Exportable);
var Provider = new AssertionFlowClient(GoogleAuthenticationServer.Description, Cert)
{
ServiceAccountId = ServiceAccountUser,
Scope = ApiUrl + "analytics.readonly"
};
var Auth = new OAuth2Authenticator<AssertionFlowClient>(Provider, AssertionFlowClient.GetState);
Service = new AnalyticsService(Auth);
}
Run Code Online (Sandbox Code Playgroud)
PrivateKeyPath是Google API控制台提供的私钥文件的路径.这在我的本地机器上完美运行,但当我把它推到我们的测试服务器时,我得到了
System.Security.Cryptography.CryptographicException: An internal error occurred.
Run Code Online (Sandbox Code Playgroud)
使用以下堆栈跟踪(删除不相关的部分):
System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr) +33
System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromFile(String fileName, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx) +0
System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String fileName, Object password, X509KeyStorageFlags keyStorageFlags) +237
System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password, X509KeyStorageFlags …Run Code Online (Sandbox Code Playgroud) 只是想知道是否有任何开箱即用的解决方案,我不太熟悉分析api也许我可以编写一些简单的js来更新分析,然后再去我的服务等等 - 否则我将不得不坚持好的旧"商店记录在数据库中".
任何帮助赞赏!
rest google-app-engine analytics google-analytics google-analytics-api
我有兴趣看到我的网站上的访问按小时分解 - 有没有办法在Google Analytics中生成此报告?似乎所有指标都只按天细分.也许我可以通过GA API获取此信息?
我使用此功能向Google Analytics发送了一些活动
_gaq.push(['_trackEvent',category,action,label,value]);
Run Code Online (Sandbox Code Playgroud)
但我发送它们只是为了测试我的代码,现在我想删除它们并开始真正的跟踪.如何删除它们?我应该使用任何代码吗?
PS:我在内容> EventTracking部分看到我的测试结果
我正在尝试从我们的Google分析实例中获取一些数据,并且我想使用适用于.NET的Analytics Reporting API V4客户端库(https://developers.google.com/api-client-library/dotnet/apis/analyticsreporting/v4)这样我就可以将一些数据烘焙到我们构建的管理站点中.我无法找到使用此代码的任何示例,文档似乎非常稀疏.我想使用服务帐户进行授权,因为我们只需要查看与我们控制的分析帐户相关联的数据.
如果有人能提供一些示例代码或指出我正确的方向使用.net api获取一些基本的报告数据,我将不胜感激
.net c# google-analytics-api google-api-dotnet-client google-analytics-firebase
我正在编写一个访问Google AnalyticsAPI的Ruby应用程序来提取一些实验信息.
该应用通过以下功能使用Google服务帐户进行连接和身份验证:
def connect
...
@@client = Google::APIClient.new(:application_name => 'My Service App',
:application_version => '1.0.0')
key_file = Rails.root.join('config', 'privatekey.p12').to_s
key_secret = 'somesecret'
key = Google::APIClient::PKCS12.load_key(key_file, key_secret)
asserter = Google::APIClient::JWTAsserter.new(
SECRETS[:google_service_account_email],
['https://www.googleapis.com/auth/yt-analytics.readonly',
'https://www.googleapis.com/auth/analytics.readonly'
],
key
)
@@client.authorization = asserter.authorize()
...
end
Run Code Online (Sandbox Code Playgroud)
...对API进行身份验证和发现,没有问题.
针对YouTube Analytics API使用客户端可以正常运行.使用相同的帐户通过...访问Analytics API
response = @@client.execute({
# 'analytics is the API object retrieved via discover_api()
:api_method => analytics.management.experiments.list,
:parameters => {
'accountId' => 'AAAAAAAA',
'profileId' => 'PPPPPPPP',
'webPropertyId' => 'UA-WWWWWWWW-#'
}
})
Run Code Online (Sandbox Code Playgroud)
结果出现403错误响应:
{"domain":"global","reason":"insufficientPermissions","message":"User does not have …Run Code Online (Sandbox Code Playgroud) google-analytics google-api google-analytics-api google-api-client
我正在尝试通过服务帐户使用Google AnalyticsAPI获取数据.
我一直在搜索stackoverflow如何做到这一点,并使用几个帖子上找到的完全相同的代码,但遇到问题,让它工作.
资料来源:
服务应用程序和Google Analytics API V3:服务器到服务器OAuth2身份验证?
服务应用程序和Google AnalyticsAPI V3:错误101(net :: ERR_CONNECTION_RESET)
这就是我得到的:
require_once('googleAPIGoogle_Client.php');
require_once('googleAPI/contrib/Google_AnalyticsService.php');
const CLIENT_ID = 'xxxxxxxx001.apps.googleusercontent.com';
const SERVICE_ACCOUNT_NAME = 'xxxxxx001@developer.gserviceaccount.com';
$keyfile = $_SERVER['DOCUMENT_ROOT']."/xxxxxxx284-privatekey.p12";
$client = new Google_Client();
$client->setAccessType('offline');
$client->setApplicationName("cc insights");
$key = file_get_contents($keyfile);
$client->setClientId(CLIENT_ID);
$client->setAssertionCredentials(new Google_AssertionCredentials(
SERVICE_ACCOUNT_NAME,
array('https://www.googleapis.com/auth/analytics.readonly'),
$key)
);
$service = new Google_AnalyticsService($client);
$data = $service->data_ga->get("ga:xxxx7777", "2012-01-01", "2013-01-25", "ga:pageviews");
var_dump($data);
Run Code Online (Sandbox Code Playgroud)
执行时我得到以下错误:
致命错误:未捕获的异常"Google_ServiceException"有消息"错误调用get https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3Axxxx7777&start-date=2012-01-01&end-date=2013- 01-25&metrics = ga%3Apageviews:(403)用户对此个人资料没有足够的权限.在/Applications/XAMPP/xamppfiles/htdocs/insights/application/libraries/googleAPI/io/Google_REST.php:66堆栈跟踪:#0 /应用/ XAMPP/xamppfiles/htdocs中/见解/应用/库/ googleAPI/IO/Google_REST .PHP(36):Google_REST :: decodeHttpResponse(对象(Google_HttpRequest))#1 /Applications/XAMPP/xamppfiles/htdocs/insights/application/libraries/googleAPI/service/Google_ServiceResource.php(178):Google_REST ::执行(对象(Google_HttpRequest))#2 /Applications/XAMPP/xamppfiles/htdocs/insights/application/libraries/googleAPI/contrib/Google_AnalyticsService.php(383):Google_ServiceResource - > __呼叫( 'GET',阵列)#3 /应用/ XAMPP/xamppfiles/htdocs中/见解/应用/库/ Google.php(46):Google_DataGaServiceResource->的get('克/Applications/XAMPP/xamppfiles/htdocs/insights/application/libraries/googleAPI/io/Google_REST.php上线66
因为我使用与工作示例完全相同的代码,我认为它可能是API或服务帐户设置的问题? …
我的网站拥有可通过以下网址访问的用户个人资料:www.domain.com/profile/123/....我想向用户显示他们的个人资料的页面查看统计信息,但需要能够做通配符.
例如,这有效:
filters=ga:pagePath==/profile/123/
Run Code Online (Sandbox Code Playgroud)
问题是可能存在其他URI段/profile/123/.我想做这样的事情(不起作用):
filters=ga:pagePath==/profile/123/*
Run Code Online (Sandbox Code Playgroud)
建议?
我曾经能够使用我的帐户的登录名和密码查询Google AnalyticsAPI.谷歌现在使用OAuth进行身份验证,这很棒......唯一的问题是我只需要一个访问令牌.我不想让其他用户获取他们的分析数据.
我只是想获取我的数据.有没有办法只为我的应用或分析帐户生成访问令牌?
我知道存在这样的解决方案......例如,Twitter为不需要特定用户登录的应用程序提供了所谓的"单用户oauth".
再一次,我在这里想要完成的是通过API获取我自己的分析数据.
有没有办法正确地做到这一点?
我有很多网站,并希望在一个页面上构建一个显示每个网站上实时访问者数量的信息中心.(还有其他人想要这个吗?)现在查看此信息的唯一方法是为每个站点打开一个新选项卡.
谷歌没有实时API,所以我想知道是否有可能刮掉这些数据.Eduardo Cereto发现Google通过实时/绑定网络请求传输实时数据.任何更精明的人都知道我应该如何开始?这就是我的想法:
检查所有实时/绑定请求以查看它们如何更改.每个请求都有唯一的密钥吗?它来自哪里?以下是我对请求的细分:
https://www.google.com/analytics/realtime/bind?VER=8
&key = [这是什么?它从何而来?21个字符小写字母数字,每个请求保持相同]
&ds = [这是什么?它从何而来?21个字符小写字母数字,每个请求保持相同]
&PAGEID = RT-标准%2Frt-概述
&Q = T%3A0%7C%3A1%3A0%3A%2CT%3A11%7C%3A1%3A5%3A%2Cot%3A0%3A0%3A4%2Cot%3A0%3A0%3A3%2CT%3A7%7C%3A1% 3A10%3A6%3D%3DREFERRAL%3B%2CT%3A10%7C%3A1%3A10%3A%2CT%3A18%7C%3A1%3A10%3A%2CT%3A4%7C5%7C2%7C%3A1%3A10%3A2! %3Dzz%3B%2C&F
q变量URI解码为this(是什么?):t:0 |:1:0:,t:11 |:1:5:,ot:0:0:4,ot:0:0:3,t :7 |:1:10:6 ==转诊;,T:10 |:1:10:,T:18 |:1:10:,T:4 | 5 | 2 |:1:10:2 = ZZ;,&F
&RID = RPC
&SID = [这是什么?它从何而来?16个字符的大写字母数字,每个请求都保持相同]
&CI = 0
&AID = [这是什么?它从何而来?整数,从1开始,奇怪地增加到150然后298]
&TYPE = XMLHTTP
&zx = [这是什么?它从何而来?12个字符的小写字母数字,更改每个请求]
&t = 1时
检查所有实时/绑定响应,看看它们是如何变化的.数据是如何进入的?它看起来像是一些改变的JSON.我需要多少次连接才能获取数据?那里的活跃访客在哪里?这是一个样本数据转储:
19 [[151,["noop"]]] 388 [[152,["rt",[{"ot:0:0:4":{"timeUnit":"MINUTES","overTimeData":[{"值":[49,53,52,40,42,55,49,41,51,52,47,42,62,82,76,71,81,66,81,86,71,66,65, 65,55,51,53,73,71,81], "姓名": "合计"}]}, "OT:0:0:3":{ "TIMEUNIT": "秒", "overTimeData":[ { "值":[0,1,1,1,1,0,1,0,1,1,1,0,2,0,2,2,1,0,0,0,0,0, 2,1,1,2,1,2,0,5,1,0,2,1,1,1,2,0,2,1,0,5,1,1,2,0,0, 0,0,0,0,0,0,0,1,1,0,3,2,0],"名称":"总计"}]}}]]]] 388 [[153,["rt ",[{ "OT:0:0:4":{ …
ajax screen-scraping google-analytics google-analytics-api web-scraping