Use Embed API to embed Google Analytics location map view

前端 未结 1 810
再見小時候
再見小時候 2021-01-06 12:42

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

相关标签:
1条回答
  • 2021-01-06 13:26

    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'
        }
      }
    });
    
    0 讨论(0)
提交回复
热议问题