How to use multiple filters with the Google Analytics Data API (GA4) using PHP
P粉704196697
P粉704196697 2023-11-04 14:39:38
0
1
571

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', ]) ]), ]), ]);


P粉704196697
P粉704196697

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!