Ahmad Khan
Ahmad Khan

Reputation: 529

GAPI, get unique visitors

how can I get all the unique visitor from the GAPI class.

$ga = new gapi(ga_email,ga_password);

$dimensions = array('visitCount');
$metrics    = array('visitors');


$ga->requestReportData(ga_profile_id, $dimensions,$metrics);

$gaResults = $ga->getResults();


//print_r( $gaResults);




$i=1;

foreach($gaResults as $result)
{

   $total= $total+ $result->getvisitors() ;
         //  $result->getVisitors()


          // );


 // print_r($result);
}

echo $total;

Upvotes: 0

Views: 2135

Answers (1)

user1190992
user1190992

Reputation: 669

$ga->requestReportData(ga_profile_id, array('pagePath'), array('visitors'));
foreach($ga->getResults() as $result) {
    var_dump($result);
}

If you check https://developers.google.com/analytics/community/export_changelog for log of Release 2011-01 (January 24, 2011).

The calculation of ga:visitors has been changed to return the number of unique visitors across the date range and now supports more dimension and metric combinations.

Upvotes: 2

Related Questions