使用 Embed API 嵌入 Google Analytics 位置图视图 [英] Use Embed API to embed Google Analytics location map view

查看:32
本文介绍了使用 Embed API 嵌入 Google Analytics 位置图视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是 Google 分析网站上的视图截图(地理 > 位置 > 主要维度 = 城市)

我想使用 google 的 Embed API 以尽可能类似的方式嵌入或复制此精确视图,并将其显示在我自己的网站上.

我已按照此处的教程进行操作 >

您可以根据各种 Google 图表库允许的选项设置图表选项.这是图表类型 GEO 的 Google 图表文档:https://developers.google.com/chart/interactive/docs/gallery/geochart#Configuration_Options

注意:您可能必须禁用弹出窗口阻止程序才能在 jsbin 中进行身份验证,但这应该会给您思路.

这是设置选项图表类型的代码部分:

vartimeline = new gapi.analytics.googleCharts.DataChart({询问: {'ids': 'ga:1234','尺寸':'ga:国家','metrics': 'ga:sessions','开始日期': '30 天前','结束日期': '昨天',},图表: {类型:'地理',容器:'时间线',选项: {region: '155',//西欧显示模式:'标记'}}});

THe below is a screenshot of a view on the Google analytics website (Geo > Location > Primary Dimension = city)

I would like to embed this exact view or replicate it as similarly as possible using google's Embed API and display it on my own site.

I have followed the tutorial here > https://developers.google.com/analytics/devguides/reporting/embed/v1/devguide and got the simple line graph working on my site but I cant seem to find any information showing how to add the map functionallity, the pie chart, or the table like we see in the below.

Are there any good examples or tutorials that could help me with this?

I tried the documentation but I just dont see a lot of explanation regarding what you can create with the API.

解决方案

How about something like this? http://jsbin.com/relufutenuto/2/edit

You can set chart options based on the options allowed by the various Google chart libraries. Here's the Google chart documentation for the chart type GEO: https://developers.google.com/chart/interactive/docs/gallery/geochart#Configuration_Options

Note: you might have to disable pop-up blockers to get auth to work in jsbin, but this should give you the idea.

Here's the part of the code that sets the chart type of options:

var timeline = new gapi.analytics.googleCharts.DataChart({
  query: {
    'ids': 'ga:1234',
    'dimensions': 'ga:country',
    'metrics': 'ga:sessions',
    'start-date': '30daysAgo',
    'end-date': 'yesterday',
  },
  chart: {
    type: 'GEO',
    container: 'timeline',
    options: {
      region: '155', // Western Europe
      displayMode: 'markers'
    }
  }
});

这篇关于使用 Embed API 嵌入 Google Analytics 位置图视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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