Google Analytics API - 是否可以进行多个查询?

Google Analytics API - Are multiple queries possible?

我想生成如下所示的 API 调用:

var dataChart5 = new gapi.analytics.googleCharts.DataChart({
    query:
    [
        {
        metrics: 'ga:totalEvents',
        dimensions: 'ga:date',
        'start-date': beginDate,
        'end-date': endDate,
        filters: 'ga:eventAction==Search;ga:eventCategory==Company'
        },
        {
        metrics: 'ga:totalEvents',
        dimensions: 'ga:date',
        'start-date': beginDate,
        'end-date': endDate,
        filters: 'ga:eventAction==Search;ga:eventCategory==Accommodation'
        }
    ],
    chart: {
        container: 'chart5-container',
        type: 'LINE',
        options: {
            width: '100%'
        }
    }
});

您会注意到为图表生成了两个查询。当我执行它时,没有任何渲染。这告诉我语法错误或者我正在尝试做的事情不受支持。这样的事情可能吗?

不,嵌入 API 无法满足您的要求。如果您检查 documentation for the DataChart component,您会看到 query 选项采用 Object 而不是 Array

要执行您想要的操作,您必须使用 Data 组件进行两次查询,然后自己呈现图表。