I want to track subfolders in Google Analytics, which are on one to five levels.
Additional obstacle is, that subfolders don't own in 100% cases trailing slash and i need to track both kind of them, with and without trailing slash, based only on the subfolder level, also /a-1/ and /a-1, /a-1/b-2/ and /a-1/b-2 and so on.
Folders look like /a-1/ and /a-1, /a-1/b-2/ and /a-1/b-2, /a-1/b-2/c-3/ and /a-1/b-2/c-3, /a-1/b-2/c-3/d-4/ and /a-1/b-2/c-3/d-4, /a-1/b-2/c-3/d-4/e-5/ and /a-1/b-2/c-3/d-4/e-5, and i need to track both of /a-1/ and /a-1 etc.
My idea was to count slashes to get the level of subfolder and then to make clear whether there is a traling slash or not to get bot variants. According to this idea matching of two subfolders, /a/b/ and /a/b would contain two rules:
- if there are 3 slashes and the string ends up with slash
- if there are 2 slashes and the string ends up without slash
This one, (.*\/){3}\/$
, should match strings, which have 3 slashes and end up with slash,
Another one, (.*\/){2}[^\/]$
, should match strings, which have 2 slashes and end up without slash.
Both rules don't work, not alone, not joined together with the pipe, as (.*\/){3}\/$|(.*\/){2}[^\/]$
- they just match something not expected.
Point me please to the solution, to the right direction.