dsuikgi9199 2017-04-06 10:15
浏览 66
已采纳

如何向Google Analytics api请求添加维度

The examples given by Google are a very simple query request. however, when I try to add more parameters, it will throw errors and I don't exactly know how to structure the syntax.

This simple query request works:

 return $analytics->data_ga->get(
  'ga:' . $viewID,
  $startDate,
  $endDate,
  'ga:sessions'
);

I need more information and I've already used Google's Query Explorer to get the Information but I just don't know how to structure my PHP query. The Information I want to request is also ga:pageviews as another metric, ga:pagePath and ga:pageTitle as dimensions and also a filter. I already fail at adding a second metric.

I have tried this:

return $analytics->data_ga->get(
  'ga:' . $viewID,
  $startDate,
  $endDate,
  'ga:sessions',
  'ga:pageviews'
);

simply adding it doesn't work. Can anyone point me in the correct direction?

  • 写回答

1条回答 默认 最新

  • dongli2000 2017-04-06 10:23
    关注

    Dimensions need to be added as option parms

    //Adding Dimensions 
    $params = array('dimensions' => 'ga:userType'); 
    // requesting the data  
    $data = $service->data_ga->get("ga:89798036", "2014-12-14", "2014-12-14", "ga:users,ga:sessions", $params );    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献