代码之家  ›  专栏  ›  技术社区  ›  Ashutosh Jha

我们能为Google Analytics v4 API添加2个以上的范围吗

  •  0
  • Ashutosh Jha  · 技术社区  · 6 年前

    我需要传递多个日期范围才能得到GA的回复。

    因为我提供了2个这样的日期范围

    dateRanges: [
                        {
                            startDate: "2018-09-01",
                            endDate: "2018-09-02"
                        },
                        {
                            startDate: "2018-09-03",
                            endDate: "2018-09-05"
                        }                  
                    ],
    

    dateRanges: [
                        {
                            startDate: "2018-09-01",
                            endDate: "2018-09-02"
                        },
                        {
                            startDate: "2018-09-03",
                            endDate: "2018-09-05"
                        },
                        {
                            startDate: "2018-09-06",
                            endDate: "2018-09-07"
                        }                    
                    ],
    

    我的回答是空的。

    完整请求

     {  
       "resource":{  
          "reportRequests":[  
             {  
                "viewId":"149278594",
                "dateRanges":[  
                   {  
                      "startDate":"2018-09-01",
                      "endDate":"2018-09-02"
                   },
                   {  
                      "startDate":"2018-09-03",
                      "endDate":"2018-09-05"
                   },
                   {  
                      "startDate":"2018-09-06",
                      "endDate":"2018-09-07"
                   }
                ],
                "metrics":[  
                   {  
                      "expression":"ga:users"
                   }
                ],
                "dimensions":[  
                   {  
                      "name":"ga:segment"
                   },
                   {  
                      "name":"ga:pagePath"
                   }
                ],
                "dimensionFilterClauses":[  
                   {  
                      "operator":"AND",
                      "filters":[  
                         {  
                            "dimensionName":"ga:pagePath",
                            "operator":"REGEXP",
                            "expressions":"^abc.com/.*"
                         }
                      ]
                   }
                ],
                "segments":[  
                   {  
                      "segmentId":"gaid::2pK67nVBSVaAOb3P-9kEog"
                   }
                ]
             }
          ]
       }
    }
    

    “data”:{“error”:{“code”:400,“message”:“请求最多可以有两个 日期范围“,”errors“:[{”message“:”请求最多可以有两个日期 范围“,”域“:”全局“,”原因“:”badRequest“}],

    1 回复  |  直到 6 年前
        1
  •  1
  •   Linda Lawton - DaImTo    6 年前
    "data":{  
       "error":{  
          "code":400,
          "message":"Request can have at most two date ranges.",
          "errors":[  
             {  
                "message":"Request can have at most two date ranges.",
                "domain":"global",
                "reason":"badRequest"
             }
          ],
    

    由于错误消息指出,您最多可以有两个日期范围,因此您有三个日期范围,而不是一个日期范围

                "dateRanges":[  
                   {  
                      "startDate":"2018-09-01",
                      "endDate":"2018-09-02"
                   },
                   {  
                      "startDate":"2018-09-03",
                      "endDate":"2018-09-05"
                   },
                   {  
                      "startDate":"2018-09-06",
                      "endDate":"2018-09-07"
                   }
                ],
    

    Issue