我必須獲取有關我的Google Analytics目標的主要信息。GAPI輸出與Google Analytics網站不匹配
我使用GAPI lib下,使用此代碼:
<?php
require_once 'conf.inc';
require_once 'gapi.class.php';
$ga = new gapi(ga_email,ga_password);
$dimensions = array('pagePath', 'hostname');
$metrics = array('goalCompletionsAll', 'goalConversionRateAll', 'goalValueAll');
$ga->requestReportData(ga_profile_id, $dimensions, $metrics,
'-goalCompletionsAll', '', '2012-09-07', '2012-10-07', 1, 500);
$gaResults = $ga->getResults();
foreach($gaResults as $result)
{
var_dump($result);
}
切這段代碼輸出:
object(gapiReportEntry)[7]
private 'metrics' =>
array (size=3)
'goalCompletionsAll' => int 12031
'goalConversionRateAll' => float 206.93154454764
'goalValueAll' => float 0
private 'dimensions' =>
array (size=2)
'pagePath' => string '/catalogs.php' (length=13)
'hostname' => string 'www.example.com' (length=13)
object(gapiReportEntry)[6]
private 'metrics' =>
array (size=3)
'goalCompletionsAll' => int 9744
'goalConversionRateAll' => float 661.05834464043
'goalValueAll' => float 0
private 'dimensions' =>
array (size=2)
'pagePath' => string '/price.php' (length=10)
'hostname' => string 'www.example.com' (length=13)
我在谷歌Analytics(分析)的網站上看到的網址目標頁面同期什麼的日期是:
Goal Completion Location Goal Completions Goal Value
1. /price.php 9,396 $0.00
2. /saloni.php 3,739 $0.00
正如你可以看到輸出不匹配。爲什麼?怎麼了?