我使用Google Analytics Javascript庫讓用戶查看他們所在頁面的地理地圖。但是,他們每次嘗試這樣做時,都必須經過身份驗證過程才能將我的數據顯示在我的頁面上。我如何找到替代方案?我只是想通過我的頁面上的可視化圖表嵌入我的分析數據,以便所有匿名觀衆可以看到它Javascript中的Google Analytics API
**我們已經創建了谷歌Analytics(分析)帳戶。 現在我們可以得到該網站的統計數據。 打開網站http://Example.com 點擊授權分析按鈕。 在打開的窗口中提供Google帳戶的憑據。 用戶名:[email protected]密碼:xxx 它會重定向到http://Example.com頁面。 輸入表格編號ga:61737784並點擊繪製圖表按鈕,然後你將得到該網站的統計數據。
我的要求是沒有登錄到谷歌分析網站我應該得到的統計數據。 因爲最終用戶不知道Google分析的憑據。 下面是HTML和JavaScript代碼。**
<script src="http://apis.google.com/js/client.js?onload=gadashInit" type="text/javascript"></script>
<script src="http://analytics-api-samples.googlecode.com/svn/trunk/src/reporting/javascript/ez-ga-dash/gadash-1.0.js" type="text/javascript"></script>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script>
<script type="text/javascript">
gadash.configKeys({
'apiKey': xxxxx',
'clientId':xxxxx'
});
var dataOverTime = new gadash.Chart();
var scoreCard = new gadash.Chart();
var sourceMediumTable = new gadash.Chart();
var baseConfig = {
'last-n-days': 30,
'query': {
'metrics': 'ga:visitors, ga:visits, ga:pageviews',
},
'chartOptions': {
width: 400
}
};
var dataOverTimeConfig = {
'divContainer': 'dataOverTimeConfig',
'type': 'LineChart',
'query': {
'dimensions': 'ga:date',
'sort': 'ga:date'
},
'chartOptions': {
height: 250,
legend: {position: 'bottom'},
hAxis: {title:'Date'},
curveType: 'function'
}
};
var scoreCardConfig = {
'divContainer': 'scorecard',
};
var sourceMediumTableConfig = {
'divContainer': 'sourceMediumTableConfig',
'query': {
'dimensions': 'ga:source,ga:medium',
'sort': '-ga:visitors',
'max-results': 100
}
};
function renderGraph() {
baseConfig.query.ids = document.getElementById('tableId').value;
dataOverTime.set(baseConfig).set(dataOverTimeConfig).render();
scoreCard.set(baseConfig).set(scoreCardConfig).render();
sourceMediumTable.set(baseConfig).set(sourceMediumTableConfig).render();
document.getElementById('ui').style.display = 'block';
return false;
}
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-33166458-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-32934024-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google.com/jsapi';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-32934024-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://') + 'analytics-api-samples.googlecode.com/svn/trunk/src/reporting/javascript/ez-ga-dash/gadash-1.0.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-32934024-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://') + 'apis.google.com/js/client.js?onload=gadashInit';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<button id="Button1" style="visibility: hidden;">
Authorize Analytics</button>
<hr />
<p>
Enter your Table ID:
<input type="text" id="tableId" />
<button onclick="return renderGraph()">
Draw Charts</button></p>
<hr />
<div id="ui" style="display: none;">
<h4>
Data Over Time</h4>
<div id="dataOverTimeConfig">
</div>
<h5>
Totals for each metric</h5>
<div id="scorecard">
</div>
<h5>
Source and Mediums by Visitor</h5>
<div id="sourceMediumTableConfig">
</div>
這樣做你有沒有成功?我試圖做同樣的事情,爲客戶建立一些報告,並希望避免登錄過程,因爲他們感到困惑! – 2012-07-16 10:48:41