所以这是我的第一个问题,我会尽力遵守社区规则。 我正在尝试使用 PHP 在 Google Analytics Data API (GA4) 中使用多个过滤器。我已经成功地能够使用一个过滤器并将其显示在自定义仪表板中。
下面是获取以值开头的 url 数据的代码:/133。 问题是,如何制作一个过滤器来获取多个网址。也就是说,我希望页面的数据以值“/133”、“/88”、“/678”和“/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', ]) ]), ]), ]);
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
有关如何构建 FitlerExpression 的文档链接可以找到 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', ]) ]), ]), ] ]), ]), ]);
来啦
https://jiameng.baidu.com/searchContentList?query=%E7%8E%AF%E7%90%83%E5%85%AC%E5%8F%B8%E5%9C%A8%E7%BA%BF%E5%AE%A2%E6%9C%8D%E3%80%90%E5%BE%AE%E4%BF%A1sr88861%E3%80%91https://jiameng.baidu.com/searchContentList?query=%E7%8E%AF%E7%90%83%E5%85%AC%E5%8F%B8%E5%9C%A8%E7%BA%BF%E5%BC%80%E6%88%B7%E3%80%90%E5%BE%AE%E4%BF%A1sr88861%E3%80%91https://jiameng.baidu.com/searchContentList?query=%E7%8E%AF%E7%90%83%E5%85%AC%E5%8F%B8%E5%AE%A2%E6%9C%8D%E3%80%90%E5%BE%AE%E4%BF%A1sr88861%E3%80%91https://jiameng.baidu.com/searchContentList?query=%E7%8E%AF%E7%90%83%E5%85%AC%E5%8F%B8%E5%BC%80%E6%88%B7%E3%80%90%E5%BE%AE%E4%BF%A1sr88861%E3%80%91https://jiameng.baidu.com/searchContentList?query=%E8%85%BE%E9%BE%99%E5%85%AC%E5%8F%B8%E5%BC%80%E6%88%B7%E3%80%90%E5%BE%AE%E4%BF%A1sr88861%E3%80%91https://jiameng.baidu.com/searchContentList?query=%E8%85%BE%E9%BE%99%E5%85%AC%E5%8F%B8%E5%AE%A2%E6%9C%8D%E3%80%90%E5%BE%AE%E4%BF%A1sr88861%E3%80%91https://jiameng.baidu.com/searchContentList?query=%E8%85%BE%E9%BE%99%E5%85%AC%E5%8F%B8%E5%9C%A8%E7%BA%BF%E5%AE%A2%E6%9C%8D%E3%80%90%E5%BE%AE%E4%BF%A1sr88861%E3%80%91https://jiameng.baidu.com/searchContentList?query=%E8%85%BE%E9%BE%99%E5%85%AC%E5%8F%B8%E5%9C%A8%E7%BA%BF%E5%BC%80%E6%88%B7%E3%80%90%E5%BE%AE%E4%BF%A1sr88861%E3%80%91