我正在尝试使用GA4 api php库来过滤维度。不幸的是,它仍然处于测试版,我找不到任何关于如何过滤维度的php示例。
我的代码返回"Expect Google\Analytics\Data\V1beta\NumericValue“。
任何帮助都将不胜感激。
$response = $client->runReport([
            'property' => 'properties/' . $property_id,
            'dateRanges' => [
                new DateRange([
                    'start_date' => 'yesterday',
                    'end_date' => 'yesterday',
                ]),
            ],
            'dimensions' => [
                new Dimension([
                    'name' => 'eventName',
                ]),
            ],
            'metrics' => [new Metric(
                [
                    'name' => 'eventCount',
                ])
            ],
            
            'metricFilter' => new FilterExpression([
                'filter' => new Filter([
                    'field_name' => 'eventCount',
                    'numeric_filter' => new Filter\NumericFilter([
                        'operation' => Filter\NumericFilter\Operation::GREATER_THAN,
                        'value' => '10000',
                    ])
                ]),
            ]),
            
        ]);下面是来自api资源管理器的请求的JSON版本:
{
  "dimensions": [
    {
      "name": "eventName"
    }
  ],
  "metrics": [
    {
      "name": "eventCount"
    }
  ],
  "dateRanges": [
    {
      "startDate": "yesterday",
      "endDate": "yesterday"
    }
  ],
  "metricFilter": {
    "filter": {
      "fieldName": "eventCount",
      "numericFilter": {
        "operation": "GREATER_THAN",
        "value": {
          "int64Value": "10000"
        }
      }
    }
  }
}发布于 2022-09-12 14:32:24
我找到了解决方案,我决定离开这篇文章,因为过滤ga4 api的内容很少。
'metricFilter' => new FilterExpression([
                'filter' => new Filter([
                    'field_name' => 'eventCount',
                    'numeric_filter' => new Filter\NumericFilter([
                        'operation' => Filter\NumericFilter\Operation::GREATER_THAN,
                        'value' => new NumericValue([
                            'int64_value'  =>  '10000'
                        ]),
                    ])
                ]),
            ]),
    ```https://stackoverflow.com/questions/73690661
复制相似问题