使用Google Analytics(分析)API创建图表,比较各个日期范围内的数据 [英] Using Google Analytics APIs to create charts comparing data across date ranges

查看:48
本文介绍了使用Google Analytics(分析)API创建图表,比较各个日期范围内的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google Analytics(分析)API创建自定义分析仪表板,并且需要包括以下受众群体概览比较:

I am using the Google Analytics API to create a custom analytics dashboard and need to include an audience overview comparison like this:

我主要使用GA Embed API.我找不到在单个Embed DataChart上创建日期范围比较表的明显方法.我尝试了几种不同的方法来创建这样的图表:

I'm mostly using the GA Embed API. I couldn't find an obvious way to create a date range comparison chart like this on a single Embed DataChart. I tried a few different approaches to create such a chart:

  • 将多个日期范围传递到Embed DataChart中:似乎没有使用多个日期范围所需的Reporting v4
  • 使用第三方chart.js库:无法使其看起来像GA图表
  • 直接使用GA报告和GA图表API生成包含两行的单个图表:无法正确显示
  • 创建两个GA嵌入数据图表,并将另一个重叠在一起

最后一种方法是唯一一种可以创建与上图中几乎完全一样的图表的方法.不幸的是,这种方法仍然存在两个问题:

The last approach is the only one with which I could create a chart almost exactly like those in the image above. Unfortunately I still have two problems with this approach:

  • 太多的GA查询减慢了页面加载速度:一个查询主图表,一个查询覆盖图,还有两个报告查询,它们首先获取图表数据以同步其垂直比例尺,因此每个总计4个查询图表.如果可以与嵌入API同时使用Reporting v4,则可以将其减少到3,但是在所有图表中仍然会有8个不必要的查询.
  • 在Google Analytics(分析)比较图中,如果日期范围不匹配,则较短的日期范围会被截断,并且从日期角度来看,两条线会匹配.我认为使用Embed DataCharts不可能做到这一点,因为查询与图表相关联,因此在显示其中一个图表之前,我无法用零填充数据.

我目前的计划是直接使用Reporting和Chart API,以减少查询的数量,并使我能够匹配日期范围以进行比较,尽管我认为Embed DataChart在将时间轴查询与& amp;;图表,因为我正在努力映射数据并使图表被标记为上图所示.

My current plan is to use the Reporting and Chart APIs directly to reduce the number of queries and enable me to match the date ranges for comparison, although I think the Embed DataChart must work some magic when it ties together a timeline query & chart because I'm struggling to map the data and get the chart to be labelled as in the above image.

是否有更好的方法可以使用Google的API生成这些日期范围比较表之一?

Is there a better way to generate one of these date range comparison charts using Google's APIs?

推荐答案

您可以使用 report api V4 来获取数据,方法是对任何使用 ga:date 维度>所需的.那么您可以使用任何图表库来绘制图形,这取决于用于叠加多个图表的图表库

you can use reporting api V4 to get data by using ga:date dimension against any metric that you want. then you can use any charting library to plot graphs , it's up to the charting library you use for superimposing multiple plots

这篇关于使用Google Analytics(分析)API创建图表,比较各个日期范围内的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆