All questions

Targeting a Strapi page by a custom plan-tier attribute, why does my CQL not match?

Asked by tomas_b on

Ttomas_b

setting a custom attribute for subscription tier. want an audience that matches paid accounts on our Strapi upgrade banner.

write:

croct.user.edit().set('custom.plan', 'pro').save()

audience CQL:

user's custom.plan is "pro"

never matches. banner always shows teh default. what am i doing wrong

Was this helpful?

2 answers

PNPetra NovakAccepted answer

The prefix is the problem, and it is the usual custom-attribute mismatch. You write custom attributes with the custom. prefix, but in CQL you reference them without it. So your write is correct:

croct.user.edit().set('custom.plan', 'pro').save()

but the condition should drop the prefix:

user's plan is "pro"

Fix the condition and the audience will start resolving.

Was this helpful?
Ttomas_b

that was exactly it. dropped the prefix in the condition and it matches now, thanks

RMRavi Menon

Worth knowing for the same audience: undefined variables evaluate to false by design, so any visitor who has not had a tier set yet simply will not match, with no error. That is correct behaviour for an upgrade banner, free and not-yet-set users just fall through to the default. The audience is evaluated in real time per interaction and attached to the experience serving the banner slot, so it re-checks on every request as people upgrade.

Was this helpful?
Still have questions?