gpt4 book ai didi

google-analytics - 如何限制分析嵌入 api 仅显示一个谷歌分析帐户

转载 作者:行者123 更新时间:2023-12-03 15:24:46 25 4
gpt4 key购买 nike

如何限制分析嵌入 api 仅显示一个谷歌分析帐户。现在我在下拉菜单下显示了三个帐户。

最佳答案

正如菲利普沃尔顿所说, View 选择器将始终显示所有帐户等。并且只有一个“ View ”,您将不需要选择器并将 id 添加到图表数据

例如,如果您要使用 https://developers.google.com/analytics/devguides/reporting/embed/v1/devguide演示作为起点。要让它只显示一个 View ,请将步骤 3 到 6 替换为:

<script>
gapi.analytics.ready(function() {

// Step 3: Authorize the user.

var CLIENT_ID = 'insert client id here';

gapi.analytics.auth.authorize({
container: 'auth-button',
clientid: CLIENT_ID,
});



// Step 4: Create the timeline chart.

var timeline = new gapi.analytics.googleCharts.DataChart({
reportType: 'ga',
query: {
'ids': 'ga:insert view id here',
'dimensions': 'ga:date',
'metrics': 'ga:sessions',
'start-date': '30daysAgo',
'end-date': 'yesterday',
},
chart: {
type: 'LINE',
container: 'timeline'
}
});

timeline.execute();


});
</script>

因此,您可以删除原始步骤的第 4 步和第 6 步,并通过将 ids: YOURVIEWID 添加到 var 时间线来编辑第 5 步。然后添加timeline.execute() 来渲染图表

可以使用 https://ga-dev-tools.appspot.com/account-explorer/ 找到所需的 ID。所需的 id 显示在“查看”下的按钮上

关于google-analytics - 如何限制分析嵌入 api 仅显示一个谷歌分析帐户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32486324/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com