dqsw7529 2014-05-19 05:31
浏览 502
已采纳

如何使用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

  • 写回答

1条回答 默认 最新

  • duangou1953 2014-05-19 06:58
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像