Google analytics keyword sort.

Hi,

I am trying to get, and sort keyword data from google analytics.

I have the beginning set up like:
[php]try {

$ga = new GoogleAnalytics($email,$password);

// set the Google Analytics profile you want to access - format is 'ga:123456';
$ga->setProfile($Id);

// set the date range we want for the report - format is YYYY-MM-DD
$ga->setDateRange($Dstart,$Dend);

// getting the report. 
$report = $ga->getReport(
	array('dimensions'=>urlencode('ga:keyword'),
		'metrics'=>urlencode('ga:visits'),

		)
	);[/php]

and I was using :
[php]//currently working
// echo "these are the organic searches from: ".$Dstart.’ to ‘.$Dend;
// echo ‘
’.’
’;
// while(list($key,$val)=each($report)){
// while(list($a,$b)=each($val)){

// echo $key.’:’.$b;

}
echo '<br>';

[/php]

However it isn’t printing out correctly. It presumably has over 400,000 values but ends in the A section.

Secondly its printing occasional weird values such as:
" amber kendrick" and " glastonbury,ct", 1 (why are there two “string” and “string”
I expected “string” , #(of visits)

Another question I have is why is there a ( ) space after the first " sign. Ex (" a) why is there a space there?
Is it simply printing that way or is $key equal to " amber kendrick" and " glastonbury,ct".
How can I get it to print (I’m using an example without the weird and) :
angel alverde losada, 1
instead of : " angel alverde losada", 1

My second issue is I need to sort it by # of words in each line. How can I do that?

It sounds like it is working just fine.

your not getting " amber kendrick" and " glastonbury,ct" your getting {" amber kendrick" and " glastonbury,ct"},1 as a single search term and 1 person who used it. AND is a google operator so it makes sense that it would not be in quotes and the individual doing the search used the " to limit their query to that specific phrase. you have a leading space because that is what the individual typed apparently.

as for your sorting option I would google php and sort.

Sponsor our Newsletter | Privacy Policy | Terms of Service