javascript 如何在自定义 CMS 中嵌入或重新创建 Google Analytics Graph
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/4480738/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to embed or recreate a Google Analytics Graph in a custom CMS
提问by Allen Gingrich
I would like to know how to create a graph with Google Analytics (maybe using the api), but I'm unsure if there is already a plugin or tutorial on how to do this. The Javascript API reference at Google.com sucks.
我想知道如何使用 Google Analytics(可能使用 api)创建图表,但我不确定是否已经有关于如何执行此操作的插件或教程。Google.com 上的 Javascript API 参考很烂。
Also any reference to how to create a line graph (canvas element?) would be great too.
此外,任何关于如何创建折线图(画布元素?)的参考也很棒。
Thanks!
谢谢!
采纳答案by Carles Barrobés
I learned to use the Google Visualization API (the one used by analytics, and the one I believe you refer to) from the examples at https://developers.google.com/chart/interactive/docsand found it quite clear.
我从https://developers.google.com/chart/interactive/docs 上的示例中学会了使用 Google Visualization API(分析使用的 API,我相信您会参考该 API),并发现它非常清楚。
You can use examples of different graphs from the Gallery as well: http://code.google.com/apis/visualization/documentation/gallery.html
您也可以使用图库中不同图表的示例:http: //code.google.com/apis/visualization/documentation/gallery.html
回答by M Schenkel
I created a service specifically for this purpose: EmbeddedAnalytics
我为此专门创建了一个服务: EmbeddedAnalytics
You define your chart type (line, bar, horizontal bar), metrics (pageviews, visits, etc), dimension (date, country,etc), and a time frame. Then you simply embed a snippet of code into your site where you want the chart to appear.
您可以定义图表类型(折线、条形、水平条)、指标(浏览量、访问量等)、维度(日期、国家/地区等)和时间范围。然后,您只需将一段代码嵌入到您希望图表显示的站点中。
回答by Collin James
Google now has an article specifically on this topic. https://developers.google.com/analytics/resources/articles/gdataAnalyticsCharts
谷歌现在有一篇专门关于这个主题的文章。 https://developers.google.com/analytics/resources/articles/gdataAnalyticsCharts
回答by Nick
Try this:
试试这个:
Google Analytics Easy Dashboard Javascript Library
Google Analytics Easy Dashboard Javascript 库
An easy way to build a custom Google Analytics Dashboard on your own page.
在您自己的页面上构建自定义 Google Analytics 仪表板的简单方法。
演示:http: //analytics-api-samples.googlecode.com/svn/trunk/src/reporting/javascript/ez-ga-dash/demos/set-demo.html
回答by Dmitry G.
Here is step-by-step guide how to embed Google Analytics chart into a webpage as interactive widget: http://explainum.blogspot.com/2011/04/how-to-add-google-analytics-chart-to.html
以下是如何将 Google Analytics 图表作为交互式小部件嵌入网页的分步指南:http: //explainum.blogspot.com/2011/04/how-to-add-google-analytics-chart-to.html
EDIT (5/15/2012): The link above goes to a blog post on Explainum -- 3rd party web-service which allows creating embeddable charts from various data sources including (and most popular) Google Analytics.
编辑(2012 年 5 月 15 日):上面的链接指向关于 Explainum 的博客文章——第三方网络服务,它允许从各种数据源创建可嵌入的图表,包括(和最流行的)谷歌分析。
Connection to GA is made using OAuth. You will need to know your GA profile ID in order to connect. Data is updated every 2-24 hours. The service is free.
使用 OAuth 建立与 GA 的连接。您需要知道您的 GA 配置文件 ID 才能连接。数据每 2-24 小时更新一次。该服务是免费的。
DISCLAIMER: I'm one of Explainum's creators.
免责声明:我是 Explainum 的创建者之一。

