google analytics api php ile veri çekmek ıstıyorumda aslında cekıyorum fakat sadece bu veriyi cekıyoırum dıger verileri nasıl çekerim
2
●2.357

<?php
require __DIR__ . '/vendor/autoload.php';
$client = new Google_Client();
$client->setAuthConfig("json dosyanız.json");
$client->setScopes(['https://www.googleapis.com/auth/analytics.readonly']);
$analytics = new Google_Service_Analytics($client);
$viewId = "id yaz";
$SayfaHit = $analytics->data_ga->get(
'ga:' . $viewId,
'7daysAgo',
'today',
'ga:sessions',
array(
'filters' => 'ga:pagePath==/seo/google-rich-snippets-nedir-nasil-eklenir.html',
'dimensions' => 'ga:pagePath',
'metrics' => 'ga:pageviews',
'sort' => '-ga:pageviews',
'max-results' => '50'
)
);
foreach($SayfaHit as $s){ ?>
<?php echo $s['0']; ?>
<?php echo $s['1']; ?>
<?php } ?>İşletim Sistemi$operatingSystem = $analytics->data_ga->get(
'ga:' . $viewId,
'30daysAgo',
'today',
'ga:sessions',
[
'dimensions' => 'ga:operatingSystem'
]
);Ülke$country = $analytics->data_ga->get(
'ga:' . $viewId,
'30daysAgo',
'today',
'ga:sessions',
[
'dimensions' => 'ga:country'
]
);Şehir$countrycc = $analytics->data_ga->get(
'ga:' . $viewId,
'30daysAgo',
'today',
'ga:sessions',
[
'dimensions' => 'ga:region'
]
);$browser = $analytics->data_ga->get(
'ga:' . $viewId,
'30daysAgo',
'today',
'ga:sessions',
[
'dimensions' => 'ga:browser'
]
);<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<div class="col-md-3">
<div id="browser" style="min-width: 310px; height: 310px; margin: 0 auto"></div>
</div>
<script type="text/javascript">
Highcharts.chart('browser', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Tarayıcı',
margin:0
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b><br>{point.percentage:.1f} %',
distance: -50,
filter: {
property: 'percentage',
operator: '>',
value: 5
}
},
showInLegend: false
}
},
series: [{
name: 'Tarayıcı',
colorByPoint: true,
data: [
<?php
foreach($browser as $br){
echo "{";
echo "name:'" .$br['0']."',";
echo "y:" .$br['1'].",";
echo "sliced: false,";
echo "selected: false";
echo "},";
}
?>
]
}]
});
</script>