如何使用google analytics api获取“平均会话持续时间”和“每次访问的平均页面数”

如何使用google analytics api获取“平均会话持续时间”和“每次访问的平均页面数”

问题描述:

Hi I am using google analytics api gapi to find 'average session duration' and 'Average pages viewed per visit' of site

I had created a dashboard for that and the values are 00:02:30 and 4.58 respectively ...

I use the following code to find it

$ga->requestReportData(ga_profile_id,array('browserVersion'),array('sessions','sessionDuration','avgSessionDuration'), $sort_metric=NULL, $filter=NULL, $fromDate, $toDate,1,50);
echo $ga->getSessionDuration(); echo '<pre>';
echo $ga->getAvgSessionDuration(); 
exit;

But the values returned is 104409 154.45118343195 any idea how to get the correct value

您好我使用google analytics api gapi code>来查找“平均会话持续时间”和' 每次访问网站时查看的平均页面 p>

我为此创建了一个仪表板,其值为 00:02:30 code>和 4.58 code >分别... p>

我使用以下代码找到它 p>

  $ ga-&gt; requestReportData(ga_profile_id,array('  browserVersion'),array('sessions','sessionDuration','avgSessionDuration'),$ sort_metric = NULL,$ filter = NULL,$ fromDate,$ toDate,1,50); 
echo $ ga-&gt; getSessionDuration()  ;  echo'&lt; pre&gt;'; 
echo $ ga-&gt; getAvgSessionDuration();  
exit; 
  code>  pre> 
 
 

但返回的值是 104409 code> 154.45118343195 code>任何想法如何获取正确的值 div>

ga:sessionDuration is type time. The total duration of user sessions represented in total seconds.

ga:avgSessionDuration is also type time. The average duration of user sessions represented in total seconds.

The API returns raw unformatted data. You will need to format it yourself. To format this in your code you should divide by 60 to get the number of minutes.