Reputation: 487
I am trying to set up a Google Analytics goal funnel for the various steps in a checkout process.
The final URL looks something like:
word/something/confirmation/000548693
or
word/something/confirmation/01857303
etc.
I don't want to set up an incorrect goal for my client, however my guess is that the expression should look like:
word/something/confirmation*
What RegEx is required to track a dynamic URL such as this that can be used in Google Analytics' goal funnel?
For reference, this particular feature in Analytics does not let you choose "begins with" or "contains" etc, like it does with various other features, it simply asks for the URL. Also worth noting this similar question, but is not the same as my question.
Upvotes: 3
Views: 2160
Reputation: 627468
Note that word/something/confirmation*
- if passed to a regex engine - will try to match word/something/confirmatio
+ 0 or more n
because *
is a special operator called a quantifier that repeats matching of the preceding atom it quantifies.
So, what you really can use is word/something/confirmation($|/.*)
where ($|/.*)
matches the end of string ($
) or /
followed with 0+ any characters but a newline.
If you plan to match URLs with word/something/confirmation/
followed with digits, you need a regex like
word/something/confirmation/[0-9]+
Where [0-9]+
matches 1 or more (as +
is also a quantifier matching 1 or more characters matching the preceding quantified subpattern).
If you are just interested in URLs with word/something/confirmation
, you might want to make sure no someword/something/confirmation123
does not get matched. You need to set boundaries with
(^|\W)word/something/confirmation($|\W)
Where (^|\W)
matches the start of string (^
) or any non-word letter (not A-Z
, nor a-z
, 0-9
, or _
) and ($|\W)
matches the end of string ($
) or a non-word character.
Upvotes: 4
Reputation: 884
If you literally only need a URL starting with word/something/confirmation/ then the regex is:
^word/something/confirmation/
Upvotes: 1