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

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

问题描述

以下是Google分析网站(Geo> Location> Primary Dimension = city)视图的屏幕截图。

我想嵌入此确切视图或复制它尽可能相似使用谷歌的Embed API,并显示在我自己的网站。

.google.com / analytics / devguides / reporting / embed / v1 / devguiderel =nofollow noreferrer> https://developers.google.com/analytics/devguides/reporting/embed/v1/devguide 和得到了简单的线条图在我的网站上工作,但我似乎找不到任何信息显示如何添加地图functionallity,饼图或表,如我们在下面看到的。



是否有任何好的示例或教程可以帮助我?

我尝试了文档,但我没有看到关于可以使用API​​创建什么的很多解释。



解决方案

这样的事情怎么样?
http://jsbin.com/relufutenuto/2/edit



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



注意:您可能有禁用弹出窗口阻止程序以获得auth在jsbin中的工作,但这应该会给你一个想法。



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

  var timeline = new gapi.analytics.googleCharts.DataChart({
query:{
' ids':'ga:1234',
'dimensions':'ga:country',
'metrics':'ga:sessions',
'start-date':'30daysAgo' ,
'end-date':'昨天',
},
图表:{
类型:'GEO',
container:'timeline',
选项:{
区域:'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天全站免登陆