需要客户端登录才能从Google Analytics数据导出API中提取数据 [英] Is Client Login required for pulling the data from google analytics data export API

查看:139
本文介绍了需要客户端登录才能从Google Analytics数据导出API中提取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ASP.NET 4.0 / javascript / jQuery / WebServices中进行编码

场景



分析帐户,我设置了 some-name@gmail.com ,密码为 pass123
我也知道表ID,比如ga:30037474



我的问题是我可以拉取数据,例如:

  // Load Google数据JavaScript客户端库。 
google.load('gdata','2.x',{packages:['analytics']});

//在库准备就绪时设置回调函数。
google.setOnLoadCallback(init);

函数init(){
myService = new google.gdata.analytics.AnalyticsService('charts_sample');
//如果客户端登录是必须的,我如何在不公开我的凭证的情况下安全地提取数据
getDataFeed();
}


/ **
*从Export API获取报表数据的主要方法。
* /
函数getDataFeed(){

myService = new google.gdata.analytics.AnalyticsService('charts_sample');
var myFeedUri = ['https://www.google.com/analytics/feeds/data',
'?start-date = 2010-06-01',
'& end-date = 2010-06-10',
'& dimensions = ga:day,ga:visitorType',
'& metrics = ga:visits',
'& sort = ga:day',
'& max-results = 20',
'& ids =',
'ga:30037474']。join('');

myService.getDataFeed(myFeedUri,handleDataFeed,handleError);
}

或者我应该在此之前认证客户吗?

如果我需要验证客户端,如果我得到一些关于如何处理这两个需求的指针,会更好。

1。无法通过在客户端暴露用户凭据进行身份验证(需要web服务类似的东西)

2.当我的站点加载时,它应该加载分析数据(不应要求登录,然后在那里拉取分析数据)。



是否有任何地方的文章?

解决方案

回答你的问题。根据您的问题的内容,您似乎对Google AnalyticsAPI具有很好的处理能力。但是有人需要授予访问Google Analytics数据的权限。使用 AuthSub 即可完成。基本上,用户需要一次性登录Google Analytics并授予您的Web服务长期使用的令牌以访问其数据。完成此操作后,您可以存储该令牌并将其与其帐户相关联,并在向Google Analytics API发送数据时传递该令牌。


Coding in ASP.NET 4.0 / javascript/ jQuery/ WebServices

The Scenario

I have an analytics account i have set up at, say, some-name@gmail.com with password as pass123 I also know the table id,say ga:30037474

My question is can I pull data like

// Load the Google data JavaScript client library.
google.load('gdata', '2.x', { packages: ['analytics'] });

// Set the callback function when the library is ready.
google.setOnLoadCallback(init);

function init() {
    myService = new google.gdata.analytics.AnalyticsService('charts_sample');
//how do i securely  pull data without exposing my credentials if client login is a must
    getDataFeed();
}


/**
* Main method to get report data from the Export API.
*/
function getDataFeed() {

    myService = new google.gdata.analytics.AnalyticsService('charts_sample');
    var myFeedUri = ['https://www.google.com/analytics/feeds/data',
    '?start-date=2010-06-01',
    '&end-date=2010-06-10',
    '&dimensions=ga:day,ga:visitorType',
    '&metrics=ga:visits',
    '&sort=ga:day',
    '&max-results=20',
    '&ids=',
    'ga:30037474'].join('');

    myService.getDataFeed(myFeedUri, handleDataFeed, handleError);
}

Or shall i authenticate the client before this?

If I need to authenticate the client, it would be better if I get some pointers on how to proceed with these two requirements.
1. Cannot authenticate by exposing the user credentials on client side(Need a webservice like thing)
2. When my site loads, it should load up with the analytics data(should not ask for login then and there to pull the analytics data).

Are there any articles anywhere?

解决方案

Not sure if this answers your question. Based on the content of your question it seems you have a very good handle on the Google Analytics API. But somewhere along the line someone will need to grant access to the Google Analytics data. Using AuthSub this can be accomplished. Basically the user will need to do a one-time login to Google Analytics and "grant" your webservice a long-lived token to access their data. Once this is done you can store this token and associate it with their account, passing it when making data calls to the Google Analytics API.

这篇关于需要客户端登录才能从Google Analytics数据导出API中提取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆