So this is my first question, I will try my best to follow the community rules. I'm trying to use multiple filters in Google Analytics Data API (GA4) using PHP. I've successfully been able to use a filter and display it in a custom dashboard.
The following is the code to get the url data starting with the value: /133. The question is, how to make a filter to get multiple urls. That is, I want the page's data to start with the values "/133", "/88", "/678" and "/67"?
$response = $client->runReport([ 'property' => 'properties/' . $property_id, 'dateRanges' => [ new DateRange([ 'start_date' => '2022-01-01', 'end_date' => 'today', ]), ], 'dimensions' => [ new Dimension(['name' => 'pageTitle',]), new Dimension(['name' => 'fullPageUrl',]), ], 'metrics' => [ new Metric(['name' => 'screenPageViews',]), new Metric(['name' => 'activeUsers',]), new Metric(['name' => 'newUsers',]), new Metric(['name' => 'userEngagementDuration',]), ], 'dimensionFilter' => new FilterExpression([ 'filter' => new Filter([ 'field_name' => 'pagePath', 'string_filter' => new FilterStringFilter([ 'match_type' => FilterStringFilterMatchType::BEGINS_WITH, 'value' => '/133', ]) ]), ]), ]);
Documentation links on how to build FitlerExpression can be found runReport([ 'property' => 'properties/' . $property_id, 'dateRanges' => [ new DateRange([ 'start_date' => '2022-01-01', 'end_date' => 'today', ]), ], 'dimensions' => [ new Dimension(['name' => 'pageTitle',]), new Dimension(['name' => 'fullPageUrl',]), ], 'metrics' => [ new Metric(['name' => 'screenPageViews',]), new Metric(['name' => 'activeUsers',]), new Metric(['name' => 'newUsers',]), new Metric(['name' => 'userEngagementDuration',]), ], 'dimensionFilter' => new FilterExpression([ 'or_group' => new FilterExpressionList([ 'expressions' => [ new FilterExpression([ 'filter' => new Filter([ 'field_name' => 'pagePath', 'string_filter' => new Filter\StringFilter([ 'match_type' => Filter\StringFilter\MatchType::BEGINS_WITH, 'value' => '/133', ]) ]), ]), new FilterExpression([ 'filter' => new Filter([ 'field_name' => 'pagePath', 'string_filter' => new Filter\StringFilter([ 'match_type' => Filter\StringFilter\MatchType::BEGINS_WITH, 'value' => '/88', ]) ]), ]), ] ]), ]), ]);