All questions

My audience condition never matches even for users it should include

Asked by Camille Aubert on

CACamille Aubert

I have an audience targeting users by company and it matches far fewer users than expected. What I tried so far:

  1. Verified the condition parses: user's company is "Acme" (no editor error)
  2. Confirmed with our backend team that we call croct.user.edit().set('company', ...) on login
  3. Tested with my own profile, which matches fine
  4. Checked a colleague's profile that should match but doesn't

The difference seems to be that some profiles never had company set at all. But shouldn't the condition throw an error then instead of silently failing? I spent half a day assuming my query was wrong

Was this helpful?

1 answer

Croct Bot
AI
Accepted answer

This is by design: undefined variables evaluate to FALSE rather than raising an error. A condition referencing an attribute the profile never set simply does not match, so evaluation always yields a clean boolean and content delivery is never interrupted by an incomplete profile.

Two implications worth internalizing:

  1. The same rule applies inside negations. not user's company is "Acme" does not match a profile with no company attribute either, because the inner expression is already undefined. "Not" branches behaving unexpectedly for profiles missing the attribute is the most common way this surprises people.
  2. When a condition underperforms, verify what the profiles actually contain before revising the query. The profile explorer in the dashboard shows every attribute stored on a profile, which would have revealed the missing company attribute immediately in your step 4.

Your query is correct; the profiles that never triggered the set('company', ...) call are excluded, which matches steps 2-4 of your investigation. See the CQL documentation for the evaluation semantics.

Was this helpful?
Still have questions?