dpdkqls6399 2017-09-28 21:52
浏览 123
已采纳

通过Google AnalyticsAPI提供AdSense数据

I have successfully implemented Google Analytics API in my Laravel app following the (rather complex) documentation. When creating this metrics object, I get the response from server, no problem there:

$sessions = new Google_Service_AnalyticsReporting_Metric();
$sessions->setExpression("ga:sessions");

However, this is the data I need:

enter image description here

So then I figured I need some other metrics inside to get the data I need and I searched on the official link for anything related to source, but which ever I used from the list I would get the following response:

"""
{

  "error": {

    "code": 400,

    "message": "Unknown metric(s): ga:source
For details see https://developers.google.com/analytics/devguides/reporting/core/dimsmets.",

    "errors": [

      {

        "message": "Unknown metric(s): ga:source
For details see https://developers.google.com/analytics/devguides/reporting/core/dimsmets.",

        "domain": "global",

        "reason": "badRequest"

      }

    ],

    "status": "INVALID_ARGUMENT"

  }

}

"""

Is there a way for me to fetch the data I need?

  • 写回答

1条回答 默认 最新

  • dongqiao0953 2017-10-05 15:53
    关注

    In case anyone wants an answer, I have solved it by using:

    //Create the Dimensions object.
    $dimensions = new Google_Service_AnalyticsReporting_Dimension();
    $dimensions->setName("ga:source");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大