Feed mappings tell Google Ads how to interpret the data within your feed for a specific context. We specify what kind of extension we're going to use the data for, and what specific field each column in the feed represents.
The extensions still won't actually appear on any ads after this step. There's one more task to complete, in the next step, to tell Google Ads exactly when to use each one.
In the example below, we're using the
FeedMappingService
to create a
FeedMapping
. The feed mapping tells Google Ads that
this feed is going to be used for sitelinks. We also explicitly state what data
each column represents, so that when the system needs to grab, for example, the
sitelink text, it knows which attribute to look at in the feed.
Ruby
client = Google::Ads::GoogleAds::GoogleAdsClient.new # The `data` in this block is the same as was used in the previous step, for # populating feed items. feed_mapping = client.resource.feed_mapping do |fm| fm.placeholder_type = :SITELINK fm.feed = data[:feed] fm.attribute_field_mappings << client.resource.attribute_field_mapping do |afm| afm.feed_attribute_id = data[:link_text_attribute_id] afm.sitelink_field = :TEXT end fm.attribute_field_mappings << client.resource.attribute_field_mapping do |afm| afm.feed_attribute_id = data[:final_url_attribute_id] afm.sitelink_field = :FINAL_URLS end fm.attribute_field_mappings << client.resource.attribute_field_mapping do |afm| afm.feed_attribute_id = data[:line_1_attribute_id] afm.sitelink_field = :LINE_1 end fm.attribute_field_mappings << client.resource.attribute_field_mapping do |afm| afm.feed_attribute_id = data[:line_2_attribute_id] afm.sitelink_field = :LINE_2 end end operation = client.operation.create_resource.feed_mapping(feed_mapping) result = client.service.feed_mapping.mutate_feed_mappings(customer_id, [operation])
You can have more than one feed mapping for a given feed. Since the feed only contains data, you could put data for more than one feed type in the same feed, and use mappings to distinguish between them. However, it is generally recommended to limit to one mapping per feed, and to only add as many attributes as are necessary, to avoid unnecessary confusion. Try to limit each feed to only one purpose, just as you would a table in a database.