什么是有效的Google Analytics比较值?

时间:2016-04-28 23:47:30

标签: google-analytics google-analytics-api google-analytics-v4

我正在尝试使用Google Analytics v4 API来获取事件操作=“myStart”时的事件数。这是我对此值的报告请求:

"reportRequests": [
  {
  "viewId": VIEW_ID,
  "dateRanges": [{
    "startDate": firstDay.format("YYYY-MM-DD"),
    "endDate": lastDay.format("YYYY-MM-DD")
  }],
  "metrics": [{"expression": "ga:eventValue"}],
  "metricFilterClauses": [{
    "filters": [{
      "metricName": "ga:eventAction",
      "operator": "EQUAL",
      "comparisonValue": "myStart"
    }]
  }]
}

我得到的回应是:

code: 400
message: 'Value for field request.metricFilterClauses.filters.comparisonValue = myStart is not valid.'
status: 'INVALID_ARGUMENT'

似乎'myValue'不是我应该发送的内容,但Google Analytics v4文档很糟糕,并没有给出这个值应该是什么的可靠示例或解释。

如何获取eventAction = myStart事件的数量?

1 个答案:

答案 0 :(得分:4)

ga:eventAction是一个维度,因此您应该使用def getPayment = Action { request => val requestOptions = new RequestOptionsBuilder() .setApiKey("sk_test_xxxxxxxxxxxxx") .build() val formData = (request.body).asFormUrlEncoded val token = formData.get("stripeToken")(0) val customerParams = Map("source" -> token, "description" -> "Customer Rollback Renew req.") val customer = Customer.create(customerParams) val chargeParams = Map("amount" -> 2000, "currency" -> "usd", "customer" -> customer.id) Charge.create(chargeParams, requestOptions); Ok } 而不是dimensionFilterClause

您可以通过查看Dimensions and Metrics Explorer来判断哪些是指标,哪些是维度。

我没有测试,但我想它看起来像这样:

metricFilterClauses