Я использую библиотеку Google Analytics Javascript, чтобы пользователи могли просматривать GeoMap конкретной страницы, на которой они находятся. Однако каждый раз, когда они пытаются это сделать, вам нужно пройти процедуру аутентификации, чтобы мои данные отображались на моей странице. Как я могу найти альтернативу этому. Я хочу встраивать свои данные Google Analytics только через визуализированный график на своей странице, чтобы его могли видеть все анонимные пользователи. Это код, где происходит процесс.
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
загрузил мои собственные данные через мой аккаунт. Геокарта находится внизу страницы.