Learn business growth with Google Analytics 4 › Forums › Google Analytics 4 › Implementing Metric Filtering in GA4 API with PHP Library › Reply To: Implementing Metric Filtering in GA4 API with PHP Library
-
Hey, I got it sorted out and thought I’d share the fix as it could help others dealing with the GA4 API. Here’s how I altered the ‘metricFilter’ section:
'metricFilter' => new FilterExpression([ 'filter' => new Filter([ 'field_name' => 'eventCount', 'numeric_filter' => new FilterNumericFilter([ 'operation' => FilterNumericFilterOperation::GREATER_THAN, 'value' => new NumericValue([ 'int64_value' => '10000' ]), ]) ]), ]),
Turns out, you need to use a ‘NumericValue’ object for the ‘value’ field. Once I did that, it worked perfectly. Hope this helps!