Użyj narzędzia FeedService
, aby utworzyć obiekt Feed
, który opisuje kształt przesyłanych danych. Plik danych jest podobny do tabeli bazy danych i może zawierać wiele elementów FeedAttribute
, które działają jako kolumny bazy danych.
Każdy atrybut ma nazwę i typ.
Ponieważ w przykładzie poniżej będziemy tworzyć dane linków do podstron, musimy określić:
- Tekst linku
- Końcowe adresy URL linków
- Wiersz 1
- Wiersz 2
Ostateczny link do podstrony może oprócz linku zawierać 2 linie tekstu.
Pamiętaj, aby określić plik danych origin
z USER
, aby poinformować Google Ads, że ten plik danych będzie uzupełniany na podstawie danych użytkownika, a nie automatycznego pliku Google Ads.
Po utworzeniu całego pliku danych musisz pobrać pełny identyfikator atrybutu, który będzie potrzebny do utworzenia danych plików w następnym kroku.
Ruby
client = Google::Ads::GoogleAds::GoogleAdsClient.new feed = client.resource.feed do |f| f.name = "example feed" f.origin = :USER # Specify the column name and data type. This is just raw data at this point, # and not yet linked to any particular purpose. The names are used to help us # remember what they are intended for later. f.attributes << client.resource.feed_attribute do |fa| fa.name = "Link Text" fa.type = :STRING end f.attributes << client.resource.feed_attribute do |fa| fa.name = "Link Final URL" fa.type = :URL_LIST end f.attributes << client.resource.feed_attribute do |fa| fa.name = "Line 1" fa.type = :STRING end f.attributes << client.resource.feed_attribute do |fa| fa.name = "Line 2" fa.type = :STRING end end operation = client.operation.create_resource.feed(feed) feed_resource_name = client.service.feed.mutate_feeds(customer_id, [operation]).results.first.resource_name # After we create the feed, we need to fetch it so we can determine the # attribute IDs, which will be required when populating feed items. feed = client.service.google_ads.search( customer_id, "select feed.attributes from feed where feed.resource_name = '#{feed_resource_name}'" ).first.feed attribute_ids = feed.attributes.map {|attribute| attribute.id}