Matching pages with regex in funnels
Write patterns that match the right page paths in a funnel step
Written By David
Last updated About 2 hours ago
When you build a funnel step of type Page visit, you choose how the page path is matched:
is: the path must be exactly what you type.
/pricingmatches/pricingand nothing else.starts with: the path must begin with what you type.
/blogmatches/blog,/blog/and/blog/seo-tips.regex: the path must match a pattern you write.
A regex (regular expression) is a short pattern that describes a family of paths. Use it when "is" and "starts with" are not enough, usually because part of the address changes from one visitor to the next, like a product name or an id in the middle of the path.
What Cromojo compares against
The pattern is checked against the page path only: the part of the address after the domain, starting with /.
So:
Never put the domain in the pattern.
example\.com/pricingmatches nothing.The query string (
?color=red) and the#part are not part of the path, so a pattern cannot match them.Matching is case-sensitive.
^/Pricing$does not match/pricing. To ignore case, start the pattern with(?i), for example(?i)^/pricing$.Special characters in the address, like spaces or accents, arrive encoded the way the browser sends them (a space is
%20).
A pattern matches anywhere unless you anchor it
This is the most common surprise. A pattern matches if it appears anywhere in the path.
^ means "the path starts here" and $ means "the path ends here". Put both around your pattern unless you really want a partial match.
Cheat sheet
Worked examples
One page, exactly
^/pricing$Same result as the "is" operator. Add ? for an optional trailing slash: ^/pricing/?$.
Any product page, but not the product list
^/products/[^/]+$Matches /products/blue-mug and /products/red-mug. Does not match /products or /products/mugs/blue.
Several pages at once
^/(pricing|plans)$Counts a visit to either /pricing or /plans as the same step.
An id in the middle of the path
^/sites/[^/]+/onboarding/install-tracking$Matches /sites/s8f2k/onboarding/install-tracking for any site id.
An optional last part
^/checkout(/thank-you)?$Matches /checkout and /checkout/thank-you.
Every page in a section, in any language folder
^/(en|fr|de)/blog/Matches /en/blog/launch, /fr/blog/lancement and so on.
Check a pattern before you save
Each step has a Test step button. It counts the visits that matched this step on its own over the selected date range. If it shows 0 for a page you know gets traffic, the pattern is probably too strict. Check the anchors, the case and any dots.
Common mistakes
Forgetting
^and$.checkoutalso matches/blog/checkout-tips. Write^/checkout$.Unescaped dots.
.means "any character", so^/guide.html$also matches/guide-html. Write^/guide\.html$.Putting the domain or
https://in the pattern. Only the path is checked.Trying to match the query string.
?utm_source=...is not part of the path, so it never matches.Wrong case.
^/Pricing$does not match/pricing. Use the real case, or start with(?i).
Limits
A pattern can be up to 500 characters.
A funnel has at most 4 steps.
Patterns use the RE2 syntax. It covers everything above, but has no look-ahead (
(?=...),(?!...)) and no back-references (\1). A pattern that uses them will not work, so test it with the Test step button first.
Was this helpful?
More in Web Analytics
Web Analytics OverviewUnderstanding Your Analytics DashboardSetting Up Conversions: Revenue or GoalsCreating & Tracking Custom EventsStill need help? Ask the team