如何让用户看到我的谷歌分析图表数据,而无需进行身份验证/登录过程
How to allow users to see my Google Analytics chart data without undergoing authentication/Sign In process
我正在使用Google Analytics Javascript库让用户查看他们所在的特定页面的GeoMap。但是,每次他们尝试这样做时,他们都必须通过身份验证过程才能在我的页面上显示我的数据。我怎么能找到一个替代方案呢?我只想嵌入我的分析数据通过可视化的图形在我的页面上,以便所有匿名观众可以看到它。这是处理发生的代码。
google.setOnLoadCallback(init);
/**
* This is called once the Google Data JavaScript library has been loaded.
* It creates a new AnalyticsService object, adds a click handler to the
* authentication button and updates the button text depending on the status.
*/
function init()
{
myService = new google.gdata.analytics.AnalyticsService('charts_sample');
/*
this is essentially the line I want to replace. It anonymously
tries to access my viewer's account.I want to set this scope such as it
address the URI of my Analytics account
*/
scope = 'https://www.google.com/analytics/feeds';
/*
if the above scope is altered to my URI then the below unnecessary login
steps will not be required at all. This is the reason why my viewers are
taken to their analytics page which is fundamentally non-existent.
*/
$("authButton").onclick = function() {
// Test if the user is not authenticated.
if (!google.accounts.user.checkLogin(scope))
{
// Authenticate the user.
google.accounts.user.login(scope);
} else
{
// Log the user out.
google.accounts.user.logout();
getStatus();
}
}
getStatus();
}
// gets the account data and then gets the outputs of the requested query
function getStatus()
{
getAccountFeed();
getDataFeed();
}
function getAccountFeed()
{
//Here agsain, I want to modify it access my account's URI
var myFeedUri ='https://www.google.com/analytics/feeds/accounts/default?max-results=50';
myService.getAccountFeed(myFeedUri, handleAccountFeed, handleError);
}
function getDataFeed()
{
var myMapPopularityFeedUri = 'https://www.google.com/analytics/feeds/data?ids=ga%3A53482361&dimensions=ga%3ApagePath%2Cga%3Acity%2Cga%3Acountry%2Cga%3Aregion%2Cga%3Alongitude%2Cga%3Alatitude&metrics=ga%3Avisitors&start-date=2011-12-01&end-date=2011-12-25&max-results=50';
myService.getDataFeed(myMapPopularityFeedUri, handleDataFeed, handleError);
}
如果你能帮忙,我将非常感激。请不要太挑剔。这是我第一个问题。相反,让我知道,我会做出我的修改。
这是一个截图嵌入看起来像我自己的点击,即GA之后通过我的账户获取我自己的数据。geoMap位于页面底部
似乎最好的方法是在分析中创建单独的共享(公共)提要(报告)。如果提要(报告)是在个人凭据下创建的,则需要授权登录才能查看或接收数据。无论使用哪个版本的OAuth或OAuth2,如果您使用请求查看站点上的数据,您应该至少使用API密钥(用于公共报告)或OAuth凭据用于个人报告。
看这个指南:
加载API并发出请求
或从本页选择任何其他示例:
Google Analytics:核心报告API客户端库示例代码(v3)
也使用这个漂亮的工具:
OAuth 2.0 Playground
为map生成API key:
Google Maps API Family
Google Maps JS API教程:Google Maps JavaScript API V3
您是否考虑过使用oAuth2进行授权?
相关文章:
- Sencha Touch和远程服务器上的身份验证
- Javascript清除缓存以清除基本身份验证凭据
- REST的面向公众的身份验证机制
- 当需要身份验证时,ui路由器不会重定向
- 使用Facebook登录,但仍然可以获得:“;此标识池不支持未经身份验证的访问“;
- AJAX HTTP基本身份验证解决方案
- 身份验证后获取Facebook图片
- 如何对单个页面进行密码保护(这不是身份验证系统的一部分)
- Twitter应用程序专用身份验证
- Passport.js成功的身份验证根本没有调用
- 通过JavaScript访问需要身份验证的页面
- UIWebview赢得't通过基本身份验证加载动态加载的资源(通过jQuery mobile)
- 使用JavaScript捕获基本身份验证凭据
- javascript中的Spotify身份验证
- ServiceStack JavaScript服务器事件客户端的身份验证
- Twitter API 1.1无法对您2进行身份验证
- javascript api,用于在第三方域上存储身份验证令牌
- 实施Facebook's无用户身份验证的Graph API
- 如何让用户看到我的谷歌分析图表数据,而无需进行身份验证/登录过程
- nodejs中的身份验证过程中出现无效salt错误