Matching Functions

CustomerFeed, CampaignFeed, and AdGroupFeed objects in AdWords allow you to define selection criteria for feed items via a matching function. A matching function consists of three fields:

Field Type
lhsOperand FunctionArgumentOperand
operator Function.Operator
rhsOperand FunctionArgumentOperand

For example, for a Function that selects FeedItems with feedItemId of 1000001, 1000002, or 1000003, the attributes are as follows:

  1. lhsOperand = RequestContextOperand with contextType = FEED_ITEM_ID
  2. operator = IN
  3. rhsOperand = [1000001, 1000002, 1000003]

As an alternative to creating operand and operator objects, you can instead set the function's functionString. You could create an equivalent function to the example above using the following function string:

IN(FEED_ITEM_ID,{1000001,1000002,1000003})

In addition to simple functions, you can combine multiple functions together to create a new function, with some restrictions (more on that later in this guide).

The sections below will explain the different rules the AdWords API uses to validate matching functions.

Example feed items

This guide will use the following feed items from fictional feed ID 12345678 as examples.

FeedItem ID Attribute 0
Name
Attribute 1
Line 2
Attribute 2
Line 3
Attribute 3
Final URLs
1000001 Mars cruise Travel at light speed 140 million miles [http://www.example.com/mars]
1000002 Venus cruise Travel at light speed 162 million miles [http://www.example.com/venus]
1000003 Jupiter cruise Lunch included 365 million miles [http://www.example.com/jupiter1, http://www.example.com/jupiter2]
1000004 Moon cruise Free pretzels 238,900 miles [http://www.example.com/moon]

Function types

The API supports the following leaf node function types. Functions composed of other functions are covered in the next section.

Selection by platform (mobile or desktop)

This function type lets you limit display of specific ad extensions (placeholder types) to mobile or desktop users.

Field Valid Value
lhsOperand RequestContextOperand with contextType = DEVICE_PLATFORM
operator EQUALS
rhsOperand a single ConstantOperand of either Mobile or Desktop (case-sensitive)
Function string example
EQUALS(CONTEXT.DEVICE,"Mobile")

Selection by feed item ID

This function type lets you select feed items by specifying their feedItemIds.

The function string below will select the first three feed items (Mars cruise, Venus cruise and Jupiter cruise) by their feed item IDs.

Field Valid Value
lhsOperand RequestContextOperand with contextType = FEED_ITEM_ID
operator EQUALS or IN
rhsOperand one or more ConstantOperands
  • must be exactly 1 ConstantOperand for EQUALS
  • max of 20 ConstantOperands for IN
Function string example
IN(FEED_ITEM_ID,{1000001,1000002,1000003})

Selection by feed attribute

This function type lets you select feed items based on the value of a specific attribute of a FeedItem.

The function string below will select the first, second, and fourth feed items by their values for attribute 0.

Field Valid Value
lhsOperand FeedAttributeOperand with feedId and feedAttributeId set
operator EQUALS or CONTAINS_ANY
rhsOperand one or more ConstantOperands
  • must be exactly 1 ConstantOperand for EQUALS
  • max of 3 ConstantOperands for CONTAINS_ANY
Function string example
CONTAINS_ANY(FeedAttribute[12345678,0],{"Mars cruise","Venus cruise","Moon cruise"})

Identity functions (always true or always false)

This function lets you define a condition that always evaluates to true or false.

The function string example below will select none of the feed items in the feed. Use this type of function to disable ad extensions of a specific type at the customer, campaign, or ad group level.

You can also use a function string of IDENTITY(true), which will select all of the feed items in the feed. However, you should only do this on a CustomerFeed for locations.

Field Valid Value
lhsOperand exactly one ConstantOperand with its booleanValue set to true or false
operator IDENTITY
rhsOperand none
Function string example
IDENTITY(false)

Combining functions

You can use FunctionOperands with the AND operator to logically combine two or more functions to form a new matching function.

The function string example below will select the first three feed items by feed item ID, but only if the impression is for a mobile device.

Field Valid Value
lhsOperand At least two FunctionArgumentOperands
operator AND
rhsOperand none
Function string example
AND(IN(FEED_ITEM_ID,{1000001,1000002,1000003}),EQUALS(CONTEXT.DEVICE,"Mobile"))

When combining functions, the lhsOperand can only consist of:

In addition, you can only use a FunctionOperand in a top level Function. You cannot nest FunctionOperands.

Here are some examples of valid and invalid function strings:

Function string Valid Notes
AND(
 IN(FEED_ITEM_ID,{1000001,1000002,
   1000003}),
 EQUALS(CONTEXT.DEVICE,"Mobile"))
Yes Valid - consists of a feed item ID function and a platform function
AND(
 CONTAINS_ANY(FeedAttribute[12345678,0],
   {"Mars cruise","Venus cruise",
    "Moon cruise"}),
 EQUALS(CONTEXT.DEVICE,"Mobile"))
    
Yes Valid - consists of a feed attribute function and a platform function
AND(
 CONTAINS_ANY(FeedAttribute[12345678,0],
   {"Mars cruise","Venus cruise",
    "Moon cruise"}),
 CONTAINS_ANY(FeedAttribute[12345678,2],
   {
     "140 million miles",
     "162 million miles"}))
    
Yes Valid - consists of two feed attribute functions
AND(
 IN(FEED_ITEM_ID,{1000001,1000002,
   1000003}),
 CONTAINS_ANY(FeedAttribute[12345678,0],
   {"Mars cruise","Venus cruise",
    "Moon cruise"}))
    
No Invalid - cannot combine feed item ID functions and feed attribute functions
AND(
 AND(
  IN(FEED_ITEM_ID,
     {1000001,1000002,1000003}),
   EQUALS(CONTEXT.DEVICE,"Mobile")),
 AND(
   CONTAINS_ANY(
     FeedAttribute[12345678,0],
     {"Mars cruise","Venus cruise",
      "Moon cruise"}),
   CONTAINS_ANY(FeedAttribute[
     12345678,1],
     {"Free pretzels","Lunch included"})
 )
)
    
No Invalid - cannot nest combining functions

Function operator rules

Below are the validation rules for each function Operator.

IN operator

The rhsOperand must contain at least 1 and no more than 20 ConstantOperand objects.

EQUALS operator

The rhsOperand must contain exactly 1 ConstantOperand object.

AND operator

The lhsOperand must contain at least 2 FunctionOperand objects. The rhsOperand should not be set.

CONTAINS_ANY operator

The rhsOperand must contain at least 1 and no more than 3 ConstantOperand objects.

IDENTITY operator

The lhsOperand must contain exactly 1 ConstantOperand with its booleanValue set. The rhsOperand should not be set.

CustomerFeed function rules

A CustomerFeed can only have one of the following placeholder types:

On a CustomerFeed matching function, you can use all of the function types and function combinations above unless the CustomerFeed is for locations.

CustomerFeed for locations

A CustomerFeed for the location placeholder type must be one of the following:

OR

CampaignFeed and AdGroupFeed function rules

You can use all of the function types and function combinations above when constructing matching functions for CampaignFeed and AdGroupFeed objects.

FeedItem targeting options

In addition to specifying a matching function at the customer, campaign, or ad group level, you can also set targeting options on individual feed items by setting the campaignTargeting, adGroupTargeting, or keywordTargeting attributes.

These targeting options will be combined with the matching function to select which feed items will be used for a given impression.

For example, let's say you create a FeedItem for sitelinks with the following targeting options:

  • adGroupTargeting.TargetingAdGroupId = 12345
  • keywordTargeting.id = 7890

You then define an AdGroupFeed for placeholder type 1 (sitelinks) with a platform matching function for Mobile.

When serving impressions for this ad group, AdWords will only serve sitelinks from the FeedItem if the impression attributes satisfy both the FeedItem targeting options and the AdGroupFeed matching function.

Example 1

Impression attributes: ad group ID 12345, keyword 7890, and a desktop user.

Result: The FeedItem will not be used because the platform (desktop) does not satisfy the AdGroupFeed matching function.

Example 2

Impression attributes: ad group ID 12345, keyword 8910, and a mobile user.

Result: The FeedItem will not be used because the keyword (7890) does not satisfy the FeedItem targeting options.

Example 3

Impression attributes: ad group ID 12345, keyword 7890, and a mobile user.

Result: The FeedItem will be used because the attributes satisfy both the AdGroupFeed matching function and the FeedItem targeting options.

Next steps

Send feedback about...

AdWords API
AdWords API
Need help? Visit our support page.