All questions

Targeting returning shoppers on Hydrogen, which CQL condition is right?

Asked by jules on

Jjules

I want to show a different homepage module to shoppers who have been to the store before versus first-timers. I have been poking at the CQL and I am not sure which condition actually captures "returning".

Here is my half-formed attempt, which I am pretty sure is wrong

user's visits is more than 1

What is the correct form for a returning visitor?

Was this helpful?

2 answers

Hhannah_croAccepted answer

The direct one is:

user is returning

That is the built-in condition for a returning visitor, no counting needed. If you want to target on deeper engagement rather than just "has been here before", you can go to the session or user stats instead, for example:

session's stats' pageviews > 3

or

user's stats' sessions is greater than 3

Pick user is returning for the plain returning-vs-new split, and the stats forms when you want a heavier-engagement segment. These are audiences, so the condition is evaluated in real time on each interaction and attached to the experience that serves your module.

Was this helpful?
Ssam_ck

One behavior that makes this clean for your first-timer case: undefined variables evaluate to false by design. So a brand-new visitor, who has no prior session or returning flag set, simply does not match the returning audience and falls through to your default module. You do not need a separate "is first time" condition, the absence handles it.

Was this helpful?
Jjules

matched exactly what I wanted, user is returning for the returning module and first-timers just get the default. thanks for the stats variants too

Still have questions?