我正在使用 Google Analytics Javascript 库让用户查看他们所在特定页面的 GeoMap。但是,每次他们尝试这样做时,您都必须通过身份验证过程才能将我的数据显示在我的页面上。我怎样才能找到替代方案。我只想通过页面上的可视化图表嵌入我的 Analytics 数据,以便所有匿名查看者都可以看到它
**我们在 Google Analytics 中创建了一个帐户。现在我们可以得到网站的统计数据了。打开站点http://Example.com 单击 Authorize Analytics 按钮。在打开的窗口中提供 Google 帐户的凭据。用户名:xxxx@gmail.com 密码:xxx 它将重定向到http://Example.com页面。输入表格 id 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>