3

I want to plot city wise Map for India to display Location based analytics on our website using Google Analytics Embed API same as displayed on google analytics dashboard. I am able to plot country wise location analytics but it fails to plot city wise map for India.

<!DOCTYPE html>
<html lang="en">

<script>
(function(w,d,s,g,js,fs){g=w.gapi||(w.gapi={});g.analytics=q:[],
ready:function(f){this.q.push(f);}};
js=d.createElement(s);fs=d.getElementsByTagName(s)[0];
js.src='https://apis.google.com/js/platform.js';
fs.parentNode.insertBefore(js,fs);js.onload=function(
{g.load('analytics');};}(window,document,'script'));
</script>

<div id="chart-1-container"></div>

<script type='text/javascript' src='https://www.google.com/jsapi'></script>

<script>

gapi.analytics.ready(function() {
  gapi.analytics.auth.authorize({
'serverAuth': {
  'access_token': 'ya29.dgL_fhSQYFuYl710ZgtPOOzeZkkRBtPdqHZ3H7-o7mlYlXXXXXXXXXXXXX'
}});

var dataChart1 = new gapi.analytics.googleCharts.DataChart({

query: {
  'ids': 'ga:98XXXXXX', // The Demos & Tools website view.
  'dimensions': 'ga:city',
  'metrics': ['ga:pageviews'],
  'start-date': '7daysAgo',
  'end-date': 'today',
  'sort' : 'ga:pageviews'
},

chart: {
  'container': 'chart-1-container',
  'type': 'GEO',
  'options': {
   'region' : '034'
  }
}
});
dataChart1.execute();
});

</script>
</html>

The image describes the exact solution I wish to have

Kenil Domadia
  • 63
  • 2
  • 9

0 Answers0