RegExp替代Google Analytics的负前瞻匹配

时间:2021-10-07 13:52:27

I'm setting up some conversion funnels on Google Analytics. One is to analyse traffic going from the main site to a secondary promotional site running on a virtual directory (on the same domain though)

我正在Google Analytics上设置一些转换渠道。一种是分析从主站点到虚拟目录上运行的辅助促销站点的流量(虽然在同一域上)

I should add, this is a setup form in Google Analytics, I can't using another other code (PHP, JS, C# etc) and it has to be done in one step

我应该补充一点,这是Google Analytics中的设置表单,我不能使用其他其他代码(PHP,JS,C#等),而且必须一步完成

So for example something like:

所以例如:

  • /default.aspx or /directory/default.aspx or /somedirname/default.aspx
  • /default.aspx或/directory/default.aspx或/somedirname/default.aspx
  • [to >]
  • [到>]
  • /promotion/default.aspx
  • /promotion/default.aspx

In regular expression land, this would be:

在正则表达式中,这将是:

  • ^/(?!promotion)(.*).aspx
  • ^ /(?!推广)(。*)。ASPX
  • [to >]
  • [到>]
  • ^/promotion/(.*).aspx
  • ^ /促销/(.*)。ASPX

The problem is Google Analytics no longer supports negative lookaheads, so the regexp ^/(?!promotion)(.*).aspx fails. (Reference here, first reply)

问题是Google Analytics不再支持否定前瞻,因此regexp ^ /(?!promotion)(。*)。aspx失败。 (参考这里,第一个回复)

Is there another way I can do this?

还有其他方法可以做到这一点吗?

Many thanks.

非常感谢。

2 个解决方案

#1


6  

You could do a two-step approach (whether that's possible in Analytics, I have no idea, though):

您可以采取两步方法(不管是否可以在Google Analytics中使用,我不知道):

  1. Replace unconditionally:
    /(.*\.aspx) --> /promotion/$1
  2. 无条件更换:/(.*\.aspx) - > / promotion / $ 1
  3. Replace again:
    /promotion/promotion/(.*) --> /promotion/$1
  4. 再次替换:/promotion/promotion/(.*) - > / promotion / $ 1

If all else fails:

如果一切都失败了:

^/(?:[^p]|p[^r]|pr[^o]|pro[^m]|prom[^o]|promo[^t]|promot[^i]|promoti[^o]|promotio[^n])/(.*)\.aspx

#2


0  

Do a match on "^/promotion/(.*).aspx" and negate the result.

在“^ / promotion /(.*).aspx”上进行匹配并否定结果。

#1


6  

You could do a two-step approach (whether that's possible in Analytics, I have no idea, though):

您可以采取两步方法(不管是否可以在Google Analytics中使用,我不知道):

  1. Replace unconditionally:
    /(.*\.aspx) --> /promotion/$1
  2. 无条件更换:/(.*\.aspx) - > / promotion / $ 1
  3. Replace again:
    /promotion/promotion/(.*) --> /promotion/$1
  4. 再次替换:/promotion/promotion/(.*) - > / promotion / $ 1

If all else fails:

如果一切都失败了:

^/(?:[^p]|p[^r]|pr[^o]|pro[^m]|prom[^o]|promo[^t]|promot[^i]|promoti[^o]|promotio[^n])/(.*)\.aspx

#2


0  

Do a match on "^/promotion/(.*).aspx" and negate the result.

在“^ / promotion /(.*).aspx”上进行匹配并否定结果。