I figured it out and can now convert a UNIT to SUBDIVISION with additional 
UNIT nodes. Firstly, thank you for getting back each time. 

For those whom I hope this helps...

*first error:*  I was pointing the "others" node parent resource to that of 
the root node criterion_id and not the new subdivision.

*second error: * I was subdividing the partition by product_item_id, I 
incorrectly configured my code to mimic the case_value property of the 
selected node and not what it was going to be subdivided by.

The example is the order of how I am doing it (order of operations).  I 
want to note though that *I only create a subdivision if a user decides to 
subdivide a node (i.e. brand or product type) that is currently a UNIT*.  
case_value for all nodes are dynamically determined based on the 
selectedNode and to be added UNIT nodes. If it's already a subdivision, 
then this process is skipped.

const updateSelectedNodeType = new resources.AdGroupCriterion({
    resource_name: tempSubdivisionResource,
    ad_group: adGroupResource,
    listing_group: {
      parent_ad_group_criterion: parentNode,
      type: enums.ListingGroupType.SUBDIVISION,
      case_value: caseValue,
    },
    negative: false,
    status: enums.AdGroupCriterionStatus.ENABLED,
  });

  const everythingElseNode = new resources.AdGroupCriterion({
    resource_name: everythingElseResource,
    ad_group: adGroupResource,
    cpc_bid_micros: toMicros(0.4),
    listing_group: {
      parent_ad_group_criterion: tempSubdivisionResource,
      type: enums.ListingGroupType.UNIT,
      case_value: everythingElseCaseValue,
    },
    negative: false,
    status: enums.AdGroupCriterionStatus.ENABLED,
  });

  const updatePartitionToSubdivision: MutateOperation<resources.
IAdGroupCriterion> =
    {
      entity: "ad_group_criterion",
      operation: "create",
      resource: {
        ...updateSelectedNodeType,
      },
    };

  createSubdivisionOperation.push(updatePartitionToSubdivision);

  const createEverythingElseNodeOperation: MutateOperation<resources.
IAdGroupCriterion> =
    {
      entity: "ad_group_criterion",
      operation: "create",
      resource: {
        ...everythingElseNode,
      },
    };
  createSubdivisionOperation.push(createEverythingElseNodeOperation);
//partition object with set cpc, but can be changed for user.
        const newPartition = new resources.AdGroupCriterion({
          ad_group: `customers/${customer}/adGroups/${adGroupId}`,
          resource_name: criterionResourceOperation,
          cpc_bid_micros: toMicros(0.4),
          negative: false,
          status: enums.AdGroupCriterionStatus.ENABLED,
          listing_group: {
            parent_ad_group_criterion: parentAdGroupCriterion,
            type: enums.ListingGroupType.UNIT,
            case_value: caseValue,
          },
        });
//finalize for operation
        const addPartitionNodes: MutateOperation<resources.IAdGroupCriterion> 
=
          {
            entity: "ad_group_criterion",
            operation: "create",
            resource: newPartition,
          };

        //push for batch operation
        addPartitionOperation.push(addPartitionNodes);


mutation: [
  {
    entity: 'ad_group_criterion',
    operation: 'create',
    resource: {
      resource_name: 'customers/2595901092/adGroupCriteria/157149367644~-1',
      ad_group: 'customers/2595901092/adGroups/157149367644',
      listing_group: [Object],
      negative: false,
      status: 2
    }
  },
  {
    entity: 'ad_group_criterion',
    operation: 'create',
    resource: {
      resource_name: 'customers/2595901092/adGroupCriteria/157149367644~-2',
      ad_group: 'customers/2595901092/adGroups/157149367644',
      cpc_bid_micros: 400000,
      listing_group: [Object],
      negative: false,
      status: 2
    }
  },
  {
    operation: 'create',
    resource: v {
      ad_group: 'customers/2595901092/adGroups/157149367644',        
      resource_name: 'customers/2595901092/adGroupCriteria/157149367644~-3',
      cpc_bid_micros: 400000,
      negative: false,
      status: 2,
      listing_group: [Object]
    }
  }
] [
//case values:
  { product_brand: { value: 'bromic' } },
  { product_item_id: {} },
  {
    product_item_id: { value: 'shopify_us_5695534235803_36317916823707' }
  }
]
Operation Success! Subdivision created.

Purely comes down to a misunderstanding on my part. Thanks for working with 
me on this.

Regards,
Michael H.



On Thursday, February 22, 2024 at 2:01:29 PM UTC+7 Google Ads API Forum 
Advisor wrote:

> Hi,
>
> Thank you for getting back to us.
>
> I understand that you are seeking assistance for 
> LISTING_GROUP_ALREADY_EXISTS 
> <https://developers.google.com/google-ads/api/reference/rpc/v16/CriterionErrorEnum.CriterionError#:~:text=of%20its%20siblings.-,LISTING_GROUP_ALREADY_EXISTS,-Listing%20group%20cannot>
>  error 
> and LISTING_GROUP_SUBDIVISION_REQUIRES_OTHERS_CASE 
> <https://developers.google.com/google-ads/api/reference/rpc/v16/CriterionErrorEnum.CriterionError#:~:text=cannot%20have%20children.-,LISTING_GROUP_SUBDIVISION_REQUIRES_OTHERS_CASE,-Subdivided%20listing%20groups>
>  
> error. Kindly double-check the ID of the listing group you are trying to 
> add. Make sure it doesn't already exist in the ad group you are adding it 
> to. You can check for this by looking for repeated creation operations for 
> the same ID or name. 
>
> As per the API documentation, a subdivision introduces a new level in the 
> tree, while units are leaves of the tree. Each subdivision must always be 
> completely partitioned, so it must contain a node representing 'Other*'*. 
> To avoid error, add 'Other' node to the subdivision. You may refer to this 
> guide 
> <https://developers.google.com/google-ads/api/docs/shopping-ads/create-listing-groups>
>  
> for more information.
>
> Regarding the above conflict between 'Others' nodes, the Google Ads API 
> requires a single "Others" node per ad group. Having two nodes with the 
> same name "Others" in the same ad group creates the conflict you're 
> encountering. Since you want to create "Others" node for each brand, the 
> earlier created 'Others' node might be redundant. You can remove it from 
> the brands partition. If you want to keep separate "Others" nodes, ensure 
> they have distinct case_value fields. This helps differentiate them in the 
> API calls. Hope this helps.
>
>   
> This message is in relation to case "ref:!00D1U01174p.!5004Q02rzEgV:ref"
>
> Thanks,
>   
> [image: Google Logo] Google Ads API Team 
>
>
>  
>
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
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 adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/fb43121d-1398-4633-b9be-5f66ad94dfa0n%40googlegroups.com.
  • Re... Jebron Lames
    • ... Jebron Lames
      • ... 'Google Ads API Forum Advisor' via Google Ads API and AdWords API Forum
        • ... Jebron Lames

Reply via email to