我正在使用Google analytics Embed api在我的网站上显示Google Analytics分析报告。我也指的是www.raymondcamden.com/2015/06/10/quick-example-of-the-google-analytics-embed-api
当我使用该演示客户端ID时,它对我来说很有用,但是当我将我的客户端ID放在浏览器控制台中显示错误而没有工作帮助时提前同样感谢 我在谷歌控制台开发者帐户中创建了凭据 为什么这段代码不起作用?使用我的Web应用程序的客户端ID
Please see the attached image for error
(function(w,d,s,g,js,fjs){
g=w.gapi||(w.gapi={});g.analytics={q:[],ready:function(cb){this.q.push(cb)}};
js=d.createElement(s);fjs=d.getElementsByTagName(s)[0];
js.src='https://apis.google.com/js/platform.js';
fjs.parentNode.insertBefore(js,fjs);js.onload=function(){g.load('analytics')};
}(window,document,'script'));
gapi.analytics.ready(function() {
// Step 3: Authorize the user.
var CLIENT_ID = 'REPLACE YOUR CLIENT ID';
gapi.analytics.auth.authorize({
container: 'auth-button',
clientid: CLIENT_ID,
});
// Step 4: Create the view selector.
var viewSelector = new gapi.analytics.ViewSelector({
container: 'view-selector'
});
// Step 5: Create the timeline chart.
var timeline = new gapi.analytics.googleCharts.DataChart({
reportType: 'ga',
query: {
'dimensions': 'ga:date',
'metrics': 'ga:sessions',
'start-date': '15daysAgo',
'end-date': 'today',
},
chart: {
type: 'LINE',
container: 'timeline'
}
});
// Step 6: Hook up the components to work together.
gapi.analytics.auth.on('success', function(response) {
viewSelector.execute();
});
viewSelector.on('change', function(ids) {
var newIds = {
query: {
ids: ids
}
}
timeline.set(newIds).execute();
});
});

<!DOCTYPE html>
<html>
<head>
<title>Embed API Demo</title>
</head>
<body>
<!-- Step 1: Create the containing elements. -->
<section id="auth-button"></section>
<section id="view-selector"></section>
<section id="timeline"></section>
</body>
</html>
&#13;