All questions

Is there a shorter way to match several page paths without a big OR chain?

Asked by marek_w on

Mmarek_w

My first attempt at an audience covering a handful of landing paths turned into this:

page's path is "/home" or page's path is "/pricing" or page's path is "/tour"

It works but it is ugly and I keep having to touch it every time we add a path. Coming from backend code I really want a set-membership check so I do not repeat the same clause. Does CQL have one

Was this helpful?

2 answers

Llena_b

It does, is in takes a list:

page's path is in ["/home", "/pricing", "/tour"]

Same result, one clause, and adding a path is just another entry in the array. It also keeps the query short, which matters because evaluated queries have a character limit and long or-chains eat into it fast.

Was this helpful?
Kkarl_h

Worth knowing it is not just for paths. The same is in form works for any single-value attribute, e.g.

location's countryName is in ["us", "ca", "mx"]

page itself exposes path, url, query, anchor and referrer, so you can build the list off whichever one fits. I use it for a small set of intent pages, similar idea to the viewed the pricing page audience.

Was this helpful?
Mmarek_w

Perfect, collapsed three of my audiences with this. Thanks both.

Still have questions?