Google Analytics API - Are multiple queries possible?

青春壹個敷衍的年華 提交于 2019-12-23 05:36:11

问题


I would like to generate an API call that looks as follows:

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%'
        }
    }
});

You'll notice there are two queries being generated for the chart. When I execute this, nothing is rendered. This tells me either the syntax is wrong or what I'm trying to do isn't supported. Is something like this possible?


回答1:


No, what you're asking is not possible with the Embed API. If you check the documentation for the DataChart component you'll see the query option takes an Object not an Array.

To do what you want, you'd have to make two queries using the Data component and then render the chart yourself.



来源:https://stackoverflow.com/questions/34245782/google-analytics-api-are-multiple-queries-possible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!