I am trying to change my scripts to use the new google analytics API within Google Docs.
I am perfectly able to retrieve my data as an array from the api which might look like:
[["01", "5", "5"], ["02", "0", "0"], ["03", "2", "2"], ["04", "2", "6"], ["05", "46", "73"], ["06", "15", "18"], ["07", "7", "7"]]
Where I am looking for some help is on how to write this to a cell. I used to do so with the v2 API, but am struggling here. (just do not understand why my old method is not working).
What I would like to do:
Call a the function from a cell (randomly chosen)
drop the results from the array to a range in my sheet. The cell where I call the function should be the first cell to write the data.
The beginning of the function would be:
function testAnalytics() {
var id = "ga:XXXXXXXX";
var startdate = "2012-01-01";
var enddate = "2012-07-31";
var metrics = "ga:visits, ga:pageviews";
var optArgs = {dimensions: "ga:month"};
var grabData = Analytics.Data.Ga.get(id,startdate, enddate,metrics,optArgs);
// Browser.msgBox(grabData.getRows()); // test to see if data is correctly received
var returnVal = grabData.getRows();
return returnVal;
/* write returnVal to active cell on active spreadsheet */
}