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.

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/b52ebdce-8c14-4323-aaac-b80ec6df4918n%40googlegroups.com.

Reply via email to