Google Analytics regex exclude a phrase

眉间皱痕 提交于 2020-05-17 12:52:50

问题


I'm creating a content grouping with the following URLs:

/my-category/something
/my-category/somethingelse
/my-category/product1-brand-color
/my-category/product2-brand-color

How to create a RegEx to group /my-category/ pages but exclude everything that has "brand"?


回答1:


Google Analytics doesn't support negative lookahead expressions. Instead, create 2 (or more) filters:

  • The first filter to include your regex using the "Only Show" dropdown
  • The second filter using the "Don't Show" dropdown containing your exclude rule



回答2:


More of a GA question than a Regex question. Regex is somewhat fussy to use in Google Analytics. Use GA's 'Advanced filter' option to include and exclude RegEx. You would get your result with either "containing" or "matching Regex" :

Include Page containing category Exclude Page containg brand




回答3:


Use a negative look-ahead.

To match /my-category/ only when it's not followed by -brand-

/my-category/(?!.*-brand-)

Or to match /my-category/ only when it's not followed by a dash (ie any brand):

/my-category/(?!.*-)



回答4:


I think you want something like this,

(?=^\/my-category)(?!.*?brand.*).*

DEMO

If you wanat this in a group then put open and close parenthesis in the pattern,

 (?=^\/my-category)(?!.*?brand.*)(.*)


来源:https://stackoverflow.com/questions/24586893/google-analytics-regex-exclude-a-phrase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!