我正在使用 Wordpress 网站显示一年前最受欢迎的文章,并且正在使用 Google Analytics 4 API
我已经到了这一点 - 代码片段过滤了以“类别”一词开头的页面。 如何过滤不以“类别”一词开头的页面?
'dimensionFilter' => new FilterExpression([
'filter' => new Filter([
'field_name' => 'pagePath',
'string_filter' => new Filter\StringFilter([
'value' => '/category',
'match_type' => Filter\StringFilter\MatchType::BEGINS_WITH
])
])
])
我已经尝试了一些 REGEX,但我不断收到 致命错误:未捕获 Google\ApiCore\ApiException:{“消息”:“值中不支持的正则表达式语法。
notExpression
中有一个FilterExpression
。所以像下面这样(我不知道你的例子是什么语言,所以我在猜测语法。):
new FilterExpression([
'notExpression' => new FilterExpression([
'filter' => new Filter([
'field_name' => 'pagePath',
'string_filter' => new Filter\StringFilter([
'value' => '/category',
'match_type' => Filter\StringFilter\MatchType::BEGINS_WITH
])
])
])
])
我希望这有帮助。