Skip to content

Commit 23b6342

Browse files
authored
Added the creation of listing group that is necessary for the PMax for retail campaign to run (#554)
1 parent 0b92847 commit 23b6342

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

examples/shopping_ads/add_performance_max_retail_campaign.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,15 @@ def _create_performance_max_campaign_operation(
251251
# For more information on Max Conversion Value, see the support article:
252252
# http://support.google.com/google-ads/answer/7684216.
253253
# A target_roas of 3.5 corresponds to a 350% return on ad spend.
254-
campaign.bidding_strategy_type = (
255-
client.enums.BiddingStrategyTypeEnum.MAXIMIZE_CONVERSION_VALUE
256-
)
257-
campaign.maximize_conversion_value.target_roas = 3.5
254+
# campaign.maximize_conversion_value.target_roas = 3.5
255+
# For first time users, it's recommended not to set a target ROAS.
256+
# Although target ROAS is optional, you still need to define it
257+
# even if you do not want to use it.
258+
campaign.maximize_conversion_value.target_roas = None
259+
# Below is what you would use if you want to maximize conversions
260+
# campaign.maximize_conversions.target_cpa = None
261+
# The target CPA is optional. This is the average amount that you would
262+
# like to spend per conversion action.
258263

259264
# Set the shopping settings.
260265
campaign.shopping_setting.merchant_id = merchant_center_account_id
@@ -263,11 +268,12 @@ def _create_performance_max_campaign_operation(
263268
# Set the Final URL expansion opt out. This flag is specific to
264269
# Performance Max campaigns. If opted out (True), only the final URLs in
265270
# the asset group or URLs specified in the advertiser's Google Merchant
266-
# Center or business data feeds are targeted.
267271
# If opted in (False), the entire domain will be targeted. For best
268272
# results, set this value to false to opt in and allow URL expansions. You
269273
# can optionally add exclusions to limit traffic to parts of your website.
270-
campaign.url_expansion_opt_out = False
274+
# For a Retail campaign, we want the final URL's to be limited to
275+
# those explicitly surfaced via GMC.
276+
campaign.url_expansion_opt_out = True
271277

272278
# Assign the resource name with a temporary ID.
273279
campaign_service = client.get_service("CampaignService")
@@ -439,6 +445,20 @@ def _create_asset_group_operation(
439445
)
440446
operations.append(mutate_operation)
441447

448+
# Creates a new ad group criterion containing the "default" listing group (All products).
449+
mutate_operation = client.get_type("MutateOperation")
450+
asset_group_listing_group = mutate_operation.asset_group_listing_group_filter_operation.create
451+
asset_group_listing_group.asset_group = asset_group_service.asset_group_path(
452+
customer_id,
453+
_ASSET_GROUP_TEMPORARY_ID,
454+
)
455+
asset_group_listing_group.type_ = client.enums.ListingGroupFilterTypeEnum.UNIT_INCLUDED
456+
# Because this is a Performance Max campaign for retail, we need to specify that this is
457+
# in the shopping vertical.
458+
asset_group_listing_group.vertical = client.enums.ListingGroupFilterVerticalEnum.SHOPPING
459+
460+
operations.append(mutate_operation)
461+
442462
# For the list of required assets for a Performance Max campaign, see
443463
# https://developers.google.com/google-ads/api/docs/performance-max/assets
444464

0 commit comments

Comments
 (0)