[英]AdSense data through Google Analytics API
遵循(相當復雜)的文檔,我已經在Laravel應用中成功實現了Google Analytics(分析)API。 創建此指標對象時,我從服務器獲得響應,那里沒有問題:
$sessions = new Google_Service_AnalyticsReporting_Metric();
$sessions->setExpression("ga:sessions");
但是,這是我需要的數據:
因此,我發現我還需要其他一些指標來獲取所需的數據,並且我在官方鏈接上搜索了與source
相關的任何內容,但是從列表中使用的任何內容,我都會得到以下響應:
"""
{\n
"error": {\n
"code": 400,\n
"message": "Unknown metric(s): ga:source\nFor details see https://developers.google.com/analytics/devguides/reporting/core/dimsmets.",\n
"errors": [\n
{\n
"message": "Unknown metric(s): ga:source\nFor details see https://developers.google.com/analytics/devguides/reporting/core/dimsmets.",\n
"domain": "global",\n
"reason": "badRequest"\n
}\n
],\n
"status": "INVALID_ARGUMENT"\n
}\n
}\n
"""
有沒有辦法讓我獲取所需的數據?
如果有人想要答案,我已經通過使用以下方法解決了:
//Create the Dimensions object.
$dimensions = new Google_Service_AnalyticsReporting_Dimension();
$dimensions->setName("ga:source");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.