Performance Max campaing error

68 views
Skip to first unread message

Radu Sitaru

unread,
Nov 1, 2022, 3:36:12 PM11/1/22
to Google Ads API and AdWords API Forum
Hello,

We try to make programatic Performance Max campaign through Ads API with Listing Groups filter by conditions.  
We follow https://developers.google.com/google-ads/api/docs/performance-max/listing-groups and https://github.com/googleads/google-ads-python/blob/00673624a3fda99c5a3fbb386aa9af8287ed07de/examples/shopping_ads/add_performance_max_product_listing_group_tree.py#L310-L427. When we try to use product_custom_attribute (to filter by Custom Label 2) we have this error: "Listing Group SUBDIVISION node must have everything else child.". The code for custom listing groups is:

def create_listing_group_filter_operation(client, customer_id):  
    operations = []
    operations.append(create_root(client, customer_id))

    new_dimension = client.get_type("ListingGroupFilterDimension")
   
    new_dimension.product_custom_attribute.index = (
        client.enums.ListingGroupFilterCustomAttributeIndexEnum.INDEX2
    )
    new_dimension.product_custom_attribute.value = "xxxxxx"

    operations.append(create_unit(client, customer_id, new_dimension, _TEMPORARY_ID_LISTING_GROUP_ROOT, 1))
   
    empty_dimension = client.get_type("ListingGroupFilterDimension")  
    empty_dimension.product_custom_attribute._pb.SetInParent()
    operations.append(
        create_unit(client, customer_id, empty_dimension, _TEMPORARY_ID_LISTING_GROUP_ROOT, 0,
        )
    )
    return operations

def create_root(client, customer_id):
    googleads_service = client.get_service("GoogleAdsService")
    mutate_operation = client.get_type("MutateOperation")
   
    asset_group_listing_group_filter = (
        mutate_operation.asset_group_listing_group_filter_operation.create
    )

    asset_group_listing_group_filter.resource_name = googleads_service.asset_group_listing_group_filter_path(
        customer_id, _ASSET_GROUP_TEMPORARY_ID, _TEMPORARY_ID_LISTING_GROUP_ROOT
    )
    asset_group_listing_group_filter.asset_group = googleads_service.asset_group_path(
        customer_id, _ASSET_GROUP_TEMPORARY_ID
    )
   
    asset_group_listing_group_filter.type_ = (
        client.enums.ListingGroupFilterTypeEnum.SUBDIVISION
    )
   
    asset_group_listing_group_filter.vertical = (
        client.enums.ListingGroupFilterVerticalEnum.SHOPPING
    )

    return mutate_operation

def create_unit(client, customer_id, dimension, parent, onoff):
    global _next_temp_id

    googleads_service = client.get_service("GoogleAdsService")
    mutate_operation = client.get_type("MutateOperation")
   
    asset_group_listing_group_filter = (
        mutate_operation.asset_group_listing_group_filter_operation.create
    )

    asset_group_listing_group_filter.resource_name = googleads_service.asset_group_listing_group_filter_path(
        customer_id, _ASSET_GROUP_TEMPORARY_ID, _next_temp_id
    )
    asset_group_listing_group_filter.asset_group = googleads_service.asset_group_path(
        customer_id, _ASSET_GROUP_TEMPORARY_ID
    )
    asset_group_listing_group_filter.parent_listing_group_filter = googleads_service.asset_group_listing_group_filter_path(
        customer_id, _ASSET_GROUP_TEMPORARY_ID, parent
    )
   
    ce = client.enums.ListingGroupFilterTypeEnum.UNIT_INCLUDED
    if onoff == 0:
        ce = client.enums.ListingGroupFilterTypeEnum.UNIT_EXCLUDED
    asset_group_listing_group_filter.type_ = (
        ce
    )

    asset_group_listing_group_filter.vertical = (
        client.enums.ListingGroupFilterVerticalEnum.SHOPPING
    )
    asset_group_listing_group_filter.case_value = dimension
   
    _next_temp_id -= 1
    return mutate_operation

Also if we use other dimension from ListingGroupFilterDimension (like product_condition) to custom the Listing Group this code is working.
There is any custom aproach for filter by Custom Label ?

Many thanks for any suggestions,
Radu.

Google Ads API Forum Advisor

unread,
Nov 2, 2022, 12:57:25 PM11/2/22
to radu....@netbridge.ro, adwor...@googlegroups.com
Hi Radu,

I think this you send us two requests about the same issues and I addressed this concerns on my reply on the other thread.

I am going to mark this one as duplicated but let us know if you have any other questions on the other thread.

Regards,
Google Logo
Daniel
Google Ads API Team
 


ref:_00D1U1174p._5004Q2fqdgZ:ref
Reply all
Reply to author
Forward
0 new messages