So far, we've set up a table with columns, populated it with rows full of data, and now are telling the system how it should interpret that data to display it in an ad. In this step, we will finally tell the system in what context to use the extension data, so that it can serve on ads. Without this step, all the data uploaded in the previous steps would never actually be used.
You can associate a feed to a customer
(CustomerFeedService
), campaign
(CampaignFeedService
), or ad group
(AdGroupFeedService
) to enable your extension for
ads in that subset of your account.
The matching function below assumes that feed items IDs were captured from the previous step, and sets up the association to limit only to those explicit feed item IDs, as well as also only showing the extensions on mobile devices. For more information on matching functions and how to craft your own, see the next step in this guide series. A matching function is required for your extensions to serve.
Ruby
client = Google::Ads::GoogleAds::GoogleAdsClient.new customer_feed = client.resource.customer_feed do |cf| cf.placeholder_types << :SITELINK cf.feed = feed_resource_name cf.matching_function = client.resource.matching_function do |mf| mf.function_string = "AND(IN(FEED_ITEM_ID,{ #{feed_item_ids.join(',')} }),EQUALS(CONTEXT.DEVICE,'Mobile'))" end end operation = client.operation.create_resource.customer_feed(customer_feed) response = client.service.customer_feed.mutate_customer_feeds(customer_id, [operation])