Is the Personalization component the right way to show a banner only to returning users?
I want to render a small banner only for returning visitors. It feels excessive to create a whole slot for it, since the banner content itself is fixed. The React SDK has a <Personalization> component and a useEvaluation hook, and I am not sure which one fits this case or how the condition is written. Is one of them intended exactly for this?
1 answer
Both fit, and a slot really is overkill for a fixed banner like this.
<Personalization> renders its children based on a CQL expression:
import {Personalization} from '@croct/plug-react';
<Personalization expression="user is returning"> {(matches: boolean) => (matches ? <ReturningBanner /> : null)}</Personalization>useEvaluation is the hook equivalent for when you need the boolean inside your own logic rather than at a render boundary:
const isReturning = useEvaluation<boolean>('user is returning');Same query language either way, so pick whichever reads better in your tree.
The dividing line worth keeping in mind: expression-based rendering is for purely structural toggles like this one, where the content is fixed and only the visibility changes. The moment marketers should be able to edit the banner copy or A/B test it, a slot is the better altitude, because then the content lives in the dashboard instead of your bundle.