0

好的,所以我有这个代码设置,我可以得到我的事件类别和动作并过滤一切......但我不能让它显示独特的事件。我在 '$result' 之后添加了 'number_format($result->uniqueEvents())' ,但这并没有返回任何内容。我究竟做错了什么?

谢谢您的帮助

define('ga_email','EMAIL');     // GA Email
define('ga_password','PASSWORD');     // 2-part authorization password
define('profile_id','PROFILE_ID');          // Analytics profile ID
require_once 'gapi/gapi.class.php';
$ga = new gapi(ga_email,ga_password);

$dimensions  = array('eventCategory','eventAction');
$metrics     = array('totalEvents','uniqueEvents', 'eventsPerVisitWithEvent');
$sort_metric = '-totalEvents';

$ga->requestReportData(profile_id,      
$dimensions, 
$metrics, 
$sort_metric, 
$filter='ga:eventAction==company', 
$start_date='2013-07-01', 
$end_date='2013-07-24', 
$start_index=1, 
$max_results=50);

$i = 1;
foreach($ga->getResults() as $result):
echo $result .  number_format($result->uniqueEvents()) . '<br>' ;

endforeach
?>
4

1 回答 1

0

这是一件简单的事情,我只是没有应用正确的指标……无论如何这对我有用。我将对此进行大量测试。当我有一些“更酷”的功能时会给出一些更新。

<?php 

define('ga_email','EMAIL');     // GA Email
define('ga_password','PASSWORD');     // 2-part authorization password
define('profile_id','PROFILE_ID');          // Analytics profile ID
require_once 'gapi/gapi.class.php';
$ga = new gapi(ga_email,ga_password);

$dimensions  = array('eventAction');
$metrics     = array('visits','totalEvents','uniqueEvents', 'eventsPerVisitWithEvent');
$sort_metric = '-totalEvents';

$ga->requestReportData(profile_id,      
$dimensions, 
$metrics, 
$sort_metric, 
$filter='ga:eventAction==' . $_GET['company'] , 
$start_date='2013-07-01', 
$end_date='2013-07-24', 
$start_index=1, 
$max_results=50);
?>
<?php
$i = 1;
foreach($ga->getResults() as $result):
echo 'Company: ' . $result . '<br> Number of Calls: ' .number_format($result- >getVisits()) .'<br>' ;

endforeach


?>
于 2013-07-30T00:40:15.673 回答