Solved

How to show a block conditionally based on whether a Custom Dimension CONTAINS some text?

  • 30 December 2020
  • 5 replies
  • 588 views

Userlevel 1
Badge +3

Glad to be new to Klaviyo!

Our profiles contain a Custom Dimension called “School Name” that might contain the word “Montessori” in it.  But it might be a longer string like “Park Street Montessori School” or “Hilltop Montessori School”.

In flows, what string do we write in this box to conditionally show (or hide)  a template box if it CONTAINS a word? 

 Is it person|lookup:’School Name’ LIKE ‘Montessori’ or maybe person|lookup:”School Name” CONTAINS ‘Montessori’ ?

Klaviyo’s tutorials seem to only use the “=” equal sign.  But we are looking for “contains”

 

icon

Best answer by retention 6 January 2021, 14:16

View original

5 replies

Userlevel 5
Badge +10

Hi @ScottCodes, not sure if you already got direction from a source elsewhere but you are able to use “in” as part of the condition so it would be something like:

 

‘Montessori’ in person|lookup:’School Name’ 

 

which would help with the contains portion. Hope this helps! 

Userlevel 1
Badge +3

Thanks!

And how do we write the reverse:  ‘if the word ‘Montessori’ is not in the field ‘School Name’?

Here is a guess:

‘Montessori’ !in person|lookup:’School Name’ 

Userlevel 7
Badge +57

Thanks!

And how do we write the reverse:  ‘if the word ‘Montessori’ is not in the field ‘School Name’?

Here is a guess:

‘Montessori’ !in person|lookup:’School Name’ 


@ScottCodes I don’t know if you’ve successfully implemented Paul’s suggestion, but if you got the “Invalid block condition” error after implementing the code, try using double quotes instead of single quotes.

Like this: "Montessori" in person|lookup:"School Name"

The reverse (or negative) version is to include “not” (without quotes) in front of the statement.

not "Montessori" in person|lookup:"School Name"

Hope this helps!

Userlevel 1
Badge +3

Thanks both @Paul S and @retention !

Will the conditional below that Paul S suggested work for a string?

The property “School Name” is a string.  

   Klaviyo’s documentation seems to suggest this structure works or searching arrays.  But maybe it also works on a string?

not "Montessori" in person|lookup:"School Name"

And thank you for the help.  

I’m MUCH happier with Klaviyo than Mailchimp which didn’t allow any conditionals like this.  They save us so much time!

Userlevel 7
Badge +57

@ScottCodes That was my initial thought too.

After testing, it turns out that it works for strings too. I replicated the scenario you’ve presented and it worked for me.

Apply it as described above and test it yourself and be sure to monitor the first couple of emails send out in case we overlooked certain aspects.

Cheers!

Reply