Jadi ini soalan pertama saya, saya akan cuba sedaya upaya untuk mengikut peraturan komuniti. Saya cuba menggunakan berbilang penapis dalam API Data Analitis Google (GA4) menggunakan PHP. Saya telah berjaya menggunakan penapis dan memaparkannya dalam papan pemuka tersuai.
Berikut ialah kod untuk mendapatkan data url bermula dengan nilai: /133. Persoalannya, bagaimana untuk membuat penapis untuk mendapatkan berbilang url. Iaitu, saya mahu data halaman bermula dengan nilai "/133", "/88", "/678" dan "/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', ]) ]), ]), ]);
Pautan dokumentasi tentang cara membina FitlerExpression boleh didapati 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', ]) ]), ]), ] ]), ]), ]);