Yandex Metrica Regex: Goals and Segments by URL Pattern

Yandex Metrica regex is a way to describe dozens of page addresses with one short pattern. It becomes useful once your site has Russian and Uzbek versions, several thank-you pages and hundreds of product cards, and listing URLs by hand stops being realistic. Below: which characters you actually need, which mistakes distort your numbers, and when a pattern is the wrong tool.

Why use a pattern instead of a list of URLs

Picture an online shop in Tashkent. A customer who pays with Click lands on one confirmation page, a Payme customer on another, and someone who orders by phone on a third. You could create three goals and stitch the reports together manually. A single pattern covers all three addresses and gives you one number.

The same logic applies to traffic analysis. Say you want to know how many search visitors went to product pages and how many read the blog. Without a pattern you would pick pages one by one. With one, you save a segment once and apply it to any report every month.

The regex characters worth learning

The regular expression language is large, but marketing tasks use a small slice of it. Learn the set below and you will cover most situations. Skip advanced constructs such as lookaheads: support varies and they are hard to verify.

  • Dot: any single character, so a literal dot in a domain should be escaped or put in square brackets
  • Asterisk: the previous character repeats any number of times, including zero
  • Plus: the previous character appears at least once
  • Vertical bar: “or”, for example rahmat|spasibo
  • Caret at the start: the match must begin at that point
  • Dollar sign at the end: the address ends there
  • Parentheses: group part of the pattern, such as (uz|ru)

Examples for a bilingual website

For the Uzbek version, write /uz/ with the closing slash. Without it, any path starting with “uz” will slip in, such as a page about Uzum delivery. For several thank-you pages, rahmat|spasibo|thank-you works: the goal fires on any of them.

Product cards with numeric IDs can be described as /product/ followed by one or more digits up to the end of the address, which keeps category pages out. For blog articles, require at least one character after /blog/, otherwise the blog home page will be counted as an article.

Tags are handy too. If you run Telegram posts or newsletters, the condition utm_source=(telegram|tg) collects all messenger traffic, even when different managers labelled their links differently.

Mistakes that distort your data

Simple oversights cause more damage than complex syntax.

  • Unescaped dot: site.uz also matches siteXuz, so escape it when precision matters
  • Overly broad pattern: the word order matches a successful order page, a “how to order” article and more, so the goal starts firing on the blog
  • Dollar sign with tracking tags: ads and newsletters append parameters after a question mark, and a strict end-of-address rule rejects them
  • Letter case: if addresses contain capitals, a lowercase pattern may miss them

How to test a pattern before saving it

Write down five addresses that must match and five that must not. Copy them from your pages report instead of inventing them. Run them through any online regex tester, and only then paste the pattern into Metrica.

It is wiser to try the pattern in a segment first: segments work on historical data, so errors show up immediately. A goal only counts from the moment it is created and is not recalculated backwards. A day after launch, compare the number of goal completions with the pages report. A big gap means the pattern catches too much or misses something.

Keep complex expressions in a shared sheet: what the pattern does, which pages it covers, when it changed. After a redesign or a URL restructure, that sheet tells you which goals and segments to recheck.

When you do not need regex at all

If “contains” or “starts with” solves the task, use it: it is easier to verify and harder to break. For leads, prefer events that your site sends from code when a form is submitted successfully. URLs change during a redesign, while the event stays. Keep patterns for grouping pages and analysis.

If you need to connect Metrica with ad platforms, your CRM and real sales, end-to-end analytics is the next step. The markdev team sets up goals, segments and reporting around the needs of businesses in Uzbekistan. Tell us what you want to measure and we will suggest where to start.

FAQ

Do I need programming skills to use regex in Yandex Metrica?

No. Eight symbols cover most tasks: dot, asterisk, plus, vertical bar, caret, dollar sign, and square and round brackets. What matters is testing the pattern on real addresses.

Why does my regex goal count extra pages?

The pattern is probably too broad. A short word matches any part of an address. Add slashes around the section or anchor the start and end of the address.

Will Metrica recalculate old data after I create a goal?

No, a goal counts from the moment of creation. Test the pattern in a segment first, since segments also work on past periods.

Which is more reliable for leads: a URL goal or an event?

An event sent from code. It does not depend on page addresses and survives a redesign. Patterns are better for analysing groups of pages.

Let’s look at your task for free

Leave your contact — in a 15-minute call we’ll show where leads get lost and what to fix first.