googleads / google-ads-ruby

Google Ads API Ruby Client Library
https://developers.google.com/google-ads/api/
Apache License 2.0
70 stars 66 forks source link

Error running Pmax listing product tree example #422

Closed diegosaul402 closed 8 months ago

diegosaul402 commented 1 year ago

I want to include this example to add a listing product tree in my codebase, but I'm getting an error when running the mutate operation at line 159

response = client.service.google_ads.mutate(
    customer_id: customer_id,
    mutate_operations: operations,
  )

Error:

Google::Ads::GoogleAds::Errors::GoogleAdsError(Google::Ads::GoogleAds::Errors::GoogleAdsError): Listing Group SUBDIVISION node must have everything else child.

This is the content of operations

[<Google::Ads::GoogleAds::V12::Services::MutateOperation: asset_group_listing_group_filter_operation: <Google::Ads::GoogleAds::V12::Services::AssetGroupListingGroupFilterOperation: create: <Google::Ads::GoogleAds::V12::Resources::AssetGroupListingGroupFilter: resource_name: "customers/2763127286/assetGroupListingGroupFilters/6458839404~-1", asset_group: "customers/2763127286/assetGroups/6458839404", id: 0, type: :SUBDIVISION, vertical: :SHOPPING, parent_listing_group_filter: "">>>,
 <Google::Ads::GoogleAds::V12::Services::MutateOperation: asset_group_listing_group_filter_operation: <Google::Ads::GoogleAds::V12::Services::AssetGroupListingGroupFilterOperation: create: <Google::Ads::GoogleAds::V12::Resources::AssetGroupListingGroupFilter: resource_name: "customers/2763127286/assetGroupListingGroupFilters/6458839404~-2", asset_group: "customers/2763127286/assetGroups/6458839404", id: 0, type: :UNIT_INCLUDED, vertical: :SHOPPING, case_value: <Google::Ads::GoogleAds::V12::Resources::ListingGroupFilterDimension: product_brand: <Google::Ads::GoogleAds::V12::Resources::ListingGroupFilterDimension::ProductBrand: value: "b1">>, parent_listing_group_filter: "customers/2763127286/assetGroupListingGroupFilters/6458839404~-1">>>,
 <Google::Ads::GoogleAds::V12::Services::MutateOperation: asset_group_listing_group_filter_operation: <Google::Ads::GoogleAds::V12::Services::AssetGroupListingGroupFilterOperation: create: <Google::Ads::GoogleAds::V12::Resources::AssetGroupListingGroupFilter: resource_name: "customers/2763127286/assetGroupListingGroupFilters/6458839404~-3", asset_group: "customers/2763127286/assetGroups/6458839404", id: 0, type: :UNIT_INCLUDED, vertical: :SHOPPING, case_value: <Google::Ads::GoogleAds::V12::Resources::ListingGroupFilterDimension: product_brand: <Google::Ads::GoogleAds::V12::Resources::ListingGroupFilterDimension::ProductBrand: value: "b2">>, parent_listing_group_filter: "customers/2763127286/assetGroupListingGroupFilters/6458839404~-1">>>]

The first operation is the result of AssetGroupListingGroupFilterCreateOperationFactory#create_root and I'm trying to put two product brands as its child b1, b2. I triple-checked and both of my brands are pointing the root node as their parent_listing_group_filter, so I'm not sure If I'm doing something wrong or if the API has problems. Any ideas on how to fix this API error?

jaredgillis commented 1 year ago

Hey Diego,

Need to make sure the entire dimension is in the tree. See this, "Each subdivision must always be completely partitioned, so it must contain a node representing Other.".

When adding the "Other" node, you can then exclude all of that group from showing by using ListingGroupFilterType. Let us know if that works.