Google Analytics regular expression for matching page URIs at specified path levels

喜你入骨 提交于 2019-12-24 05:27:34

问题


I am trying to build a regular expression for a page-level report in Google Analytics to match pages that exist at a specified level in the path/directory, and exclude pages in the report beyond that level.

More specifically, to only show page URIs in the report that are at the 5th path level, or rather, URIs that contain 5 "/"s only, and no more.

(The seperate drill-down content report in Analytics only offers separation to 4 levels in the path, which is therefore not suitable in this case.)

Any help would be much appreciated.

Thanks.

Edit:

Using an example below, I am currently able to build a regular expression that matches the following Page URIs:

/about/team/member1/bio/info
/about/team/member2/bio/address
/about/team/member2/bio/address?=2335
/about/team/member3/bio/contact
/about/team/member3/bio/contact/method
/about/team/member4/bio/p321
/about/team/member4/bio/p321/test

However I would like the regular expression to exclude the pages above in rows 3,5 and 7 or any other page URIs for that matter that exceed 5 levels in the path. Also, just to add, that the 5th level in the path could contain any letters and/or numbers.


回答1:


I'm not sure which regex flavor GA uses, but this is fairly standard and matches all the rows except 3,5 and 7.

^(?:/[a-zA-Z0-9]+){1,5}$

In case GA doesn't support non-capturing groups, go with this:

^(/[a-zA-Z0-9]+){1,5}$


来源:https://stackoverflow.com/questions/23031093/google-analytics-regular-expression-for-matching-page-uris-at-specified-path-lev

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