How do i add a single product id to a shopping campaign in JAVA

79 views
Skip to first unread message

Thomas Bisballe

unread,
Aug 28, 2018, 11:44:04 PM8/28/18
to AdWords API and Google Ads API Forum
How do i add a single product id from merchant center into a new Adgroup in a new shopping campaign in JAVA
with a cpc bid of 2 euros 
and make it exclude everything else in "all products"

Peter Oliquino (AdWords API Team)

unread,
Aug 29, 2018, 4:34:25 AM8/29/18
to adwor...@googlegroups.com
Hi Thomas,

You can review our shopping campaigns guide on how you can configure your accounts and create shopping campaigns with their corresponding bids and product partitions and set its product dimensions (ProductOfferId).

As for excluding "everything else", I'm afraid that there is no direct way to achieve this. Using the AdGroupCriterionService.mutate() method, you will have to REMOVE it and ADD it again, however this time, you will need to ADD it as a NegativeAdGroupCriterion.

Best regards,
Peter
AdWords API Team

Thomas Bisballe

unread,
Aug 30, 2018, 12:10:02 PM8/30/18
to AdWords API and Google Ads API Forum
Hi Peter
Im building upon the addShoppingCampaign.java code

changed the code a little too

    if (createDefaultPartition) {
      // Create an ad group criterion for 'All products' using the ProductPartitionTree utility.
      ProductPartitionTree productPartitionTree =
          ProductPartitionTree.createAdGroupTree(adWordsServices, session, adGroup.getId());
      productPartitionTree
      .getRoot().asSubdivision().addChild(ProductDimensions.createOfferId("9420020220386")).asBiddableUnit().setBid(900000L);
           
      List<AdGroupCriterionOperation> mutateOperations = productPartitionTree.getMutateOperations();

      // Make the mutate request.
      AdGroupCriterionServiceInterface adGroupCriterionService =
          adWordsServices.get(session, AdGroupCriterionServiceInterface.class);
      AdGroupCriterionReturnValue adGroupCriterionResult =
          adGroupCriterionService.mutate(
              mutateOperations.toArray(new AdGroupCriterionOperation[0]));

      // Display result.
      for (AdGroupCriterion adGroupCriterion : adGroupCriterionResult.getValue()) {
        System.out.printf(
            "Ad group criterion with ID %d in ad group with ID %d was added.%n",
            adGroupCriterion.getCriterion().getId(), adGroupCriterion.getAdGroupId());
      }


And getting
  Error 1: AdGroupCriterionError{apiErrorType=AdGroupCriterionError, errorString=AdGroupCriterionError.PRODUCT_PARTITION_SUBDIVISION_REQUIRES_OTHERS_CASE, fieldPath=operations, fieldPathElements=[FieldPathElement{field=operations}], reason=PRODUCT_PARTITION_SUBDIVISION_REQUIRES_OTHERS_CASE, trigger=ProductPartition{id=TempCriterionId{id=1}, bidSimulatorStatus=null, partitionType=SUBDIVISION, parentCriterionId=null, productGroup=null, productGroupObsoleteStatus=null, caseValue=null, decisionPath=[], salesCountry=null, merchantId=null, hasPromotedSuggestion=null}}

what is meant by PRODUCT_PARTITION_SUBDIVISION_REQUIRES_OTHERS_CASE and how do i fix it

Peter Oliquino (AdWords API Team)

unread,
Aug 30, 2018, 11:08:08 PM8/30/18
to AdWords API and Google Ads API Forum
Hi Thomas,

Could you confirm if you received my response in private? If you haven't, you may refer below for its contents :

"The error you are encountering indicates that the product partitions you subdivide must have an "Others" case. Each of your subdivisions must always be completely partitioned and include an "Others" category.

You can refer to this sample code and then add the Others category. Let me know if this helps."

Best regards,
Peter
AdWords API Team

Reply all
Reply to author
Forward
0 new messages