user3526779
user3526779

Reputation: 23

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

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.

Upvotes: 2

Views: 1469

Answers (1)

zx81
zx81

Reputation: 41838

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}$

Upvotes: 1

Related Questions