在Google Analytics中搜索和替换请求URI过滤器



我有 2 个登陆页面:

/aa/index.php/aa/index/[sessionID]/alpha
/bb/index.php/bb/index/[sessionID]/bravo

由于会话 ID 是唯一的,因此每个着陆页都将作为不同的页面进行跟踪。因此,我需要一个过滤器来删除会话 ID。这些是我想跟踪的:

/aa/index.php/aa/index/alpha
/bb/index.php/bb/index/bravo

我在请求 URI 上创建了搜索和替换自定义筛选器:

Search String: /(aa|bb)/index.php/(aa|bb)/index/(.*)
Replace String: /$1/index.php/$2/index/$3

但是第二天我在仪表板上报告了/$1/index.php/$2/index/$3。所以我尝试了/1/index.php/2/index/3但我得到了非常奇怪的结果,//aa/index.php/aa/index/alpha/index.php/aa/index/aa.

有谁知道如何在替换字符串中引用分组模式?

我的解决方案:我设法使用高级过滤器解决了它。我的解决方案:

Field A => Request URI: /(aa|bb)/index.php/(aa|bb)/index/(.*)/(.*) 
Field B => - 
Output to => Request URI: /$A1/index.php/$A2/index/$A4

我没有使用Google Analytics正则表达式引擎,但在我看来,1引用了整个匹配(在其他正则表达式实现中称为),而2是第一组,3是第二组,依此类推。

但是,您的初始正则表达式看起来不完整 - 我认为它应该如下所示:

Search String: /(aa|bb)/index.php/(aa|bb)/index(/.*)/(alpha|bravo)
Replace String: /2/index.php/3/index/5

(请注意,我不确定此正则表达式实现是否支持?作为非贪婪修饰符,但如果是,如果将/.*更改为/.*?,上述搜索字符串模式可能会运行得更快一些。

最新更新