Skip to main content
Web Analytics

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. /pricing matches /pricing and nothing else.

  • starts with: the path must begin with what you type. /blog matches /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 /.

Visitor's address

Path Cromojo checks

https://www.example.com/pricing

/pricing

https://www.example.com/products/blue-mug?color=red

/products/blue-mug

https://www.example.com/docs#install

/docs

So:

  • Never put the domain in the pattern. example\.com/pricing matches 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.

Pattern

Matches

Also matches

pricing

/pricing

/blog/pricing-tips, /old-pricing

^/pricing

/pricing

/pricing/teams, /pricing-old

^/pricing$

/pricing

nothing else

^ 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

Symbol

Meaning

Example

Matches

^

start of the path

^/blog

/blog/post but not /en/blog

$

end of the path

/thank-you$

/checkout/thank-you but not /thank-you/again

.

any one character

^/v.$

/v1, /v2

.*

anything, including nothing

^/docs/.*

every page under /docs/

[^/]+

one path segment (anything up to the next /)

^/products/[^/]+$

/products/blue-mug but not /products/mugs/blue

(a|b)

either a or b

^/(pricing|plans)$

/pricing, /plans

?

the thing before it is optional

^/pricing/?$

/pricing, /pricing/

\.

a real dot

^/guide\.html$

/guide.html

[0-9]+

one or more digits

^/orders/[0-9]+$

/orders/1042

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 $. checkout also 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.