I am trying to filter dimensions with the GA4 api php library. Unfortunately, it is still in beta and I can't find any php examples on how to filter dimensions.
My code returns "Expect Google\Analytics\Data\V1beta\NumericValue."
Any help would be appreciated.
$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',
])
]),
]),
]);
Here is the JSON version of the request from the api explorer:
{
"dimensions": [
{
"name": "eventName"
}
],
"metrics": [
{
"name": "eventCount"
}
],
"dateRanges": [
{
"startDate": "yesterday",
"endDate": "yesterday"
}
],
"metricFilter": {
"filter": {
"fieldName": "eventCount",
"numericFilter": {
"operation": "GREATER_THAN",
"value": {
"int64Value": "10000"
}
}
}
}
}