About IF functions

IF functions allow you to insert a specific message in your text ad when a condition is met, and a default text when it does not. This makes your ads tailored to each search and more relevant to potential customers. Unlike ad customizers, IF functions do not use a feed.

How it works

IF functions only work for ads shown on the Search Network. IF functions are parameters that go within braces {like this}. The parameter gets replaced by the text you specify when your ad is triggered by a person’s search. You can include IF functions anywhere in your text ad except for the final URL field.

Supported targets

 

Target Attribute Code Example

device

mobile

{=IF(device=mobile, text to insert):default text}

{=IF(device=mobile,Quick\, Easy\, Mobile Booking):Best price guarantee}

audience

 

any valid user list name in your account

{=IF(audience IN(<userlist1>,<userlist2>),text to insert):default text}

{=IF(audience IN(returning visitors, cart abandoners),30%):25%}

If you're targeting by audience, make sure your ads follow the Personalized advertising policy.

Keep in mind

 
  • Certain special characters need to be escaped inside IF functions by using a backslash (\). An escape is a way of representing a character in the source code, which allows it to be displayed properly. 
  • Single straight quotes (‘), double straight quotes (‘ ’), single curly quotes(“), and double curly quotes (“ ”) must be escaped if inside a string literal (" "). 
  • Backslashes (\) must always be escaped. 
  • A colon (:) should be escaped if it's part of a feed name or attribute name. 
  • A comma (,) must be escaped if used in unquoted strings. 
  • Parentheses ( ) must be escaped if used in unquoted user list names. 
  • If quotes appear in a string surrounded by a different type of quote, they don’t need to be escaped. Example, you can have a single quote in a string if it's surrounded by double quotes (“ ‘ “).

Examples

Tailor your message for mobile users.

Google Ads Google Search

Headline 1: Kids Basketball Shoes

Headline 2: Save 20% on Top Brands

Headline 3: Family-Owned Business

Description: Get The Best Shoes At The Best Price. {=IF(device=mobile,Free Shipping on Mobile Orders!):Buy Now!}

Mobile

Kids Basketball Shoes | Save 20% On Top Brands | Family-Owned Business
Ad www.example.com
Get The Best Shoes At The Best Price. Free Shipping On Mobile Orders!

 

Desktop

Kids Basketball Shoes | Save 20% On Top Brands | Family-Owned Business
Ad www.example.com
Get The Best Shoes At The Best Price. Buy Now!
 

Give cart abandoners an extra incentive to complete the transaction.

Google Ads Google Search

Headline 1: Kids Basketball Shoes

Headline 2: Save {=IF(audience IN(Cart Abandoners),30%):20%} on Top Brands

Headline 3: Family-Owned Business

Description: Get The Best Shoes At The Best Price. Free Shipping. Buy Now! 

Audience = cart abandoners

Kids Basketball Shoes | Save 30% On Top Brands | Family-Owned Business
Ad www.example.com
Get The Best Shoes At The Best Price. Buy Now!
 

Other audiences

Kids Basketball Shoes | Save 20% On Top Brands | Family-Owned Business
Ad www.example.com
Get The Best Shoes At The Best Price. Buy Now!
The character limit for your ads may vary for double-width character languages. Make sure your ads follow the Editorial advertising policy.

Related links

Was this article helpful?
How can we improve it?