Hello, I just got started working with the google analytics api. This little function works nice for me to get the TOTAL amount of visits from 2012-03-03 to 2012-03-06. function getResults(&$analytics, $profileId) { return $analytics->data_ga->get( 'ga:' . $profileId, '2012-03-03', '2012-03-06', 'ga:visits'); } PHP: However, I want the result to be returned in an array where I am presented with the amount of visits per day, for each of the days between the two dates. How can I achive this? Thanks in advance.
if it's a string your getting try explode on the substring whitespaces to assemble values and loop though. eg: <?php $array = explode(" ", $your_input_string); //your array sorting/filtering code here print_r($array); ?> PHP: On the other hand you need to call the regex engine to process data on the fly there's preg_split too. This will explode on all character returns - whitespace, tabs, returns etc. (from doc's) eg: <?php $array = preg_split("/[\s,]+/", $your_input_string); //split string by any number of commas or space characters including " ", \r, \t, \n and \f //your array sorting/filtering code here print_r($array); ?> PHP: ROOFIS
Thank you for the reply, but the issue is not in how to explode strings, but rather that I want analytics to return all the visitor counts for EACH day. As I mentioned, right now it returns the TOTAL for all the days in between. So the question is, what do I need to query the API for, in order to get that returned from the analytics API.