おかげで、これが私のコードである解決策が見つかりました:
gapi.client.analytics.data.ga.get({
'ids': 'ga:' + profileId,
'start-date': '31daysAgo',
'end-date': 'today',
'dimensions': 'ga:pageTitle,ga:deviceCategory',
'metrics':'ga:visits,ga:sessions,ga:pageviews'
}).then(function(response) {
var formattedJson = JSON.stringify(response.result, null, 2);
//send the values to some label
$("#visitasReport").text(response.result.totalsForAllResults["ga:visits"]);
$("#duracionReport").text(response.result.totalsForAllResults["ga:sessions"]);
var arregloPaginas = [],arregloDevices = [];
var totalTablet=0,totalMobil=0,totalDesktop=0;
function Array(t, a, l) {
this.titulo = t;
this.a = a;
}
for(var x=0;x<response.result.rows.length;x++){
if(response.result.rows[x][2]!=0){
var a = new Array(response.result.rows[x][0],response.result.rows[x][2]);
arregloPaginas.push(a);
//calculate the numbers of visits view the console.log(response.result)
if(response.result.rows[x][1]=="mobile"){totalMobil+=parseInt(response.result.rows[x][2]);}
if(response.result.rows[x][1]=="desktop"){totalDesktop+=parseInt(response.result.rows[x][2]);}
if(response.result.rows[x][1]=="tablet"){totalTablet+=parseInt(response.result.rows[x][2]);}
}
}
$("#reportDesktop").text(totalDesktop);
$("#reportMobile").text((totalTablet+totalMobil));
var totalVisits=response.result.totalsForAllResults["ga:visits"];
//send data to Charts
Morris.Bar({
element: 'morris-bar-chart',
data:arregloPaginas,
xkey: 'titulo',
ykeys: ['a'],
labels: ['Visitas'],
hideHover: 'auto',
resize: true
});
Morris.Donut({
element: 'morris-donut-chart',
data: [
{label: "Celulares",value: Math.round((totalMobil*100)/totalVisits)},
{label: "Escritorio",value: Math.round((totalDesktop*100)/totalVisits)},
{label: "Tablets",value: Math.round((totalTablet*100)/totalVisits)}
],
resize: true
});
/********************************/
}).then(null, function(err) {
// Log any errors.
console.log(err);
});
これがダッシュボードです