Skip to content

Commit

Permalink
V15: Update PMax retail example to use Global Offers / feedLabel (#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfrg authored Oct 20, 2023
1 parent 5635425 commit 8028a89
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ def create_campaign(client, customer_id, merchant_center_id, campaign_budget_id)
c.shopping_setting = client.resource.shopping_setting do |ss|
ss.campaign_priority = 0
ss.merchant_id = merchant_center_id.to_i

# Display Network campaigns do not support partition by country. The only
# supported value is "ZZ". This signals that products from all countries
# are available in the campaign. The actual products which serve are based
# on the products tagged in the user list entry.
ss.sales_country = "ZZ"
ss.enable_local = true
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ def create_root(client)
lgf.type = :SUBDIVISION

# Because this is a Performance Max campaign for retail, we need to
# specify that this is in the SHOPPING vertical.
lgf.vertical = :SHOPPING
# specify that this is in the SHOPPING listing source.
lgf.listing_source = :SHOPPING
end

client.operation.mutate do |m|
Expand Down Expand Up @@ -361,8 +361,8 @@ def create_subdivision(client, parent, id, dimension)
lgf.type = :SUBDIVISION

# Because this is a Performance Max campaign for retail, we need to
# specify that this is in the SHOPPING vertical.
lgf.vertical = :SHOPPING
# specify that this is in the SHOPPING listing source.
lgf.listing_source = :SHOPPING

lgf.case_value = dimension
end
Expand Down Expand Up @@ -401,8 +401,8 @@ def create_unit(client, parent, id, dimension)
lgf.type = :UNIT_INCLUDED

# Because this is a Performance Max campaign for retail, we need to
# specify that this is in the SHOPPING vertical.
lgf.vertical = :SHOPPING
# specify that this is in the SHOPPING listing source.
lgf.listing_source = :SHOPPING

lgf.case_value = dimension
end
Expand Down
21 changes: 8 additions & 13 deletions examples/shopping_ads/add_performance_max_retail_campaign.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def next_temp_id
def add_performance_max_retail_campaign(
customer_id,
merchant_center_account_id,
sales_country,
final_url)
# [START add_performance_max_retail_campaign_1]
# GoogleAdsClient will read a config file from
Expand Down Expand Up @@ -114,7 +113,6 @@ def add_performance_max_retail_campaign(
client,
customer_id,
merchant_center_account_id,
sales_country,
)
campaign_criterion_operations = create_campaign_criterion_operations(
client,
Expand Down Expand Up @@ -193,8 +191,7 @@ def create_campaign_budget_operation(client, customer_id)
def create_performance_max_campaign_operation(
client,
customer_id,
merchant_center_account_id,
sales_country)
merchant_center_account_id)
client.operation.mutate do |m|
m.campaign_operation = client.operation.create_resource.campaign do |c|
c.name = "Performance Max retail campaign #{SecureRandom.uuid}"
Expand Down Expand Up @@ -222,7 +219,11 @@ def create_performance_max_campaign_operation(
# Set the shopping settings.
c.shopping_setting = client.resource.shopping_setting do |ss|
ss.merchant_id = merchant_center_account_id
ss.sales_country = sales_country
# Optional: To use products only from a specific feed, set feed_label
# to the feed label used in Merchant Center.
# See: https://support.google.com/merchants/answer/12453549.
# Omitting the feed_label field will use products from all feeds.
# feed_label = "INSERT_FEED_LABEL_HERE"
end

# Set the Final URL expansion opt out. This flag is specific to
Expand Down Expand Up @@ -382,8 +383,8 @@ def create_listing_group_filter_operation(client, customer_id)
)
aglg.type = :UNIT_INCLUDED
# Because this is a Performance Max campaign for retail, we need to
# specify that this is in the shopping vertical.
aglg.vertical = :SHOPPING
# specify that this is in the shopping listing source.
aglg.listing_source = :SHOPPING
end
end
end
Expand Down Expand Up @@ -679,7 +680,6 @@ def print_response_details(response)
# Running the example with -h will print the command line usage.
options[:customer_id] = 'INSERT_CUSTOMER_ID_HERE'
options[:merchant_center_account_id] = 'INSERT_MERCHANT_CENTER_ACCOUNT_ID_HERE'
options[:sales_country] = 'INSERT_SALES_COUNTRY_HERE'
options[:final_url] = 'INSERT_FINAL_URL_HERE'

OptionParser.new do |opts|
Expand All @@ -697,10 +697,6 @@ def print_response_details(response)
options[:merchant_center_account_id] = v
end

opts.on('-s', '--sales-country-id SALES-COUNTRY', String, 'Sales Country') do |v|
options[:sales_country] = v
end

opts.on('-f', '--final-url FINAL-URL', String, 'Final URL') do |v|
options[:final_url] = v
end
Expand All @@ -718,7 +714,6 @@ def print_response_details(response)
add_performance_max_retail_campaign(
options.fetch(:customer_id).tr("-", ""),
options.fetch(:merchant_center_account_id),
options.fetch(:sales_country),
options.fetch(:final_url))
rescue Google::Ads::GoogleAds::Errors::GoogleAdsError => e
e.failure.errors.each do |error|
Expand Down
1 change: 0 additions & 1 deletion examples/shopping_ads/add_shopping_product_ad.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def add_standard_shopping_campaign(

campaign.shopping_setting = client.resource.shopping_setting do |shopping_setting|
shopping_setting.merchant_id = merchant_center_id
shopping_setting.sales_country = "US"
shopping_setting.campaign_priority = 0
shopping_setting.enable_local = true
end
Expand Down

0 comments on commit 8028a89

Please sign in to comment.