[eluser]Ludovic-r[/eluser]
I need your help because I'm stuck on how to get secondary datas from Google API and show them on a graph, let me explain :
I've successfully retrieved "visits" datas from the Google Analytics API and show them on my chart with this code :
Code:
$report3 = $ga->getReport(
array('dimensions'=>urlencode('ga:date'),
'metrics'=>urlencode('ga:pageviews,ga:visits'),
'filters'=>urlencode(''),
'sort'=>'ga:date'
)
);
Which give me an array like :
Code:
[20110726] => Array
(
[ga:pageviews] => 0
[ga:visits] => 0
)
Then I put these informations on the chart with :
Code:
[removed]
var ga_data = [
<?php
$str = "";
foreach ($report3 as $value)
$str.="{$value["ga:visits"]},";
$str = rtrim($str,",");
echo $str;
?>
];
[removed]
And finally :
Code:
// Create the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Month');
data.addColumn('number', 'visits');
data.addRows(ga_data.length*1);
for (i=9; i<ga_data.length; i++){
data.setValue(i, 0, 'DATE NEEDED');
data.setValue(i, 1, ga_data[i]);
}
The only problem is that I need to show the DATE : ([
20110726] => Array ( [ga:pageviews] => 0 [ga:visits] => 0 )) on the chart like I do with visits
Any help will be very very appreciated ! Thanks !!!