Docs

PostHog Flag Conditions: Tracking String-Match Targeting

PostHog added starts-with/ends-with feature flag conditions — what to track to confirm string-match targeting reaches the right users.

Analytics

PostHog recently extended its feature flag property conditions to support “starts with”, “doesn’t start with”, “ends with”, and “doesn’t end with” matching, all case-insensitive, alongside the existing exact-match and contains operators. That sounds like a small syntax addition, but it changes how teams can safely target rollouts. Before this, targeting a flag at every user whose email domain ended in a specific suffix, or whose device ID carried a particular prefix, meant either an exact-match list that needed constant upkeep or a regex condition that was easy to get subtly wrong. A flag with a slightly wrong regex doesn’t fail loudly — it just quietly includes or excludes the wrong slice of users, and nobody notices until a support ticket or a skewed experiment result shows up.

The real risk with any new targeting operator is the gap between what the condition is supposed to match and what it actually matches once real, messy production data hits it. Free-text fields like email or device identifiers carry casing inconsistencies, trailing whitespace, and unexpected characters that a rule written against clean test data won’t anticipate. Teams that migrate existing regex-based flags to the new string-match operators, or start using them for the first time, need to verify the resulting audience before trusting a flag to gate a feature or a paid tier.

Data Points to Track

  • Flag evaluation count by matched condition type, so you can see how many evaluations resolved via the new starts-with/ends-with operators versus older exact-match or regex conditions
  • Audience size before and after switching a flag to a string-match condition, to catch an unexpectedly large or small target group immediately after a change
  • Property value samples that triggered a true match, logged for a sample of evaluations, so you can spot-check whether the matched values are what you intended
  • Flag key, condition definition, and last-modified timestamp, so any audience-size anomaly can be traced back to the specific rule change that caused it
  • Downstream conversion or error rate for users gated by the new condition type, to catch a mistargeted rollout before it affects a large cohort

Setup Steps

  1. Inventory existing regex-based flags that could be simplified to the new starts-with/ends-with operators, since simpler conditions are easier to audit and less likely to silently misfire.
  2. Run the new condition against a snapshot of production property values before flipping a live flag, comparing the resulting match count against the old condition’s match count.
  3. Instrument a flag-evaluation event that records the flag key, the condition type that matched, and a hashed or truncated version of the matched property value.
  4. Set an alert on sudden audience-size shifts for any flag tied to a paid feature, a compliance-sensitive rollout, or an A/B test, so a targeting change gets caught within hours rather than at the next manual review.
  5. Document the case-insensitivity behaviour for your team, since a condition that used to be case-sensitive under a custom regex may now match more broadly than before.

Actionable Insights

Once you’re tracking match-type and audience-size data, the practical use is catching targeting drift before it becomes a support or trust problem: a flag whose audience size jumps 3x after a condition edit is a signal to pause and check the matched values, not to assume the new operator “just works” the same way the old regex did. Over time, the flag-evaluation event data also tells you which condition types your team actually relies on — if starts-with and ends-with quickly become the dominant pattern for domain- or prefix-based targeting, that’s a signal to standardise your flag conventions around them instead of leaving regex conditions in place for consistency’s sake alone.

Expert help

Need help tracking this in your app?

Our team sets up analytics pipelines for mobile and web teams every day. Talk to us and get your first events flowing in under an hour.

Talk to an expert