contains

Evaluates to true when needle is a substring of haystack, or when needle is the same as haystack.

Syntax

contains(needle, haystack)

needle and haystack can be any of the following:

  • A String constant, such as "GDN".
  • A Search Ads 360 variable that is a String, such as Keyword, Campaign, Engine_status, and so on.
  • An expression or formula column that returns a String.

Case insensitive

Text comparisons are case insensitive. That is, contains("gdn", "GDN") evaluates to true.

Empty character

If you include an expression or formula column in this function, the expression or formula column could evaluate to an empty string.

Be aware that all strings contain an empty (zero-length) String. That is, contains("", "GDN") evaluates to true.

Note that contains("GDN", "") evaluates to false. That is, an empty string does not contain non-empty Strings.

Examples

  • [contains("hook", "fishhook")]
    evaluates to true

  • If a keyword contains "hoopers", display "brand". For other keywords, display "non-brand":
    [if(contains("hoopers", keyword), "brand", "non-brand")]

  • If a keyword contains "hoopers" and is contained in a campaign that starts with "US", display "US brand":
    [if(and(contains("hoopers", keyword), starts_with(campaign, "US")), "US brand", "non-brand")]

  • If campaign contains "Shopping" or "GDN" or "RLSA", display "budget 1", for others display "budget 2":
    [if(or(contains("Shopping", campaign), contains("GDN", campaign), contains("RLSA", campaign)), "budget 1", "budget 2")]

Was this helpful?
How can we improve it?