Create copy of entire shopping campaign

79 views
Skip to first unread message

ph...@brainlabsdigital.com

unread,
Aug 25, 2016, 4:07:48 AM8/25/16
to AdWords API Forum
Hi,

I am trying to take an existing shopping campaign and duplicate it exactly (different name) within the same account.

I have done the adgroups and campaign creation, but am confused by what I do / do not need to specify when adding the product partition to the ad groups. Please see my method below. I would appreciate it if you were able to shed some light on this.

1) Retrieve all AdGroupCriterion in my adgroup with CriteriaType "PRODUCT_PARTITION", fields downloaded: "AdGroupId", "CpcBid", "CriteriaType", "PartitionType", "CaseValue"
2) Extract the root criterion like so:

    foreach ($partitions as $partition)
    {
      if ($partition->criterion->parentCriterionId == "")
      {
        $adGroupId = $partition->adGroupId;
        $roots[$adGroupId] = $partition;
      }
    }

3) Add the partition to the adgroup:

  $oldPartition = root criterion found above;

  $service  = $user->GetService("AdGroupCriterionService", ADWORDS_VERSION);
  $adGroupCriterion = new BiddableAdGroupCriterion();
  $adGroupCriterion->adGroupId = $adGroup->getId();

  $adGroupCriterion->criterion = $oldPartition->criterion;
  $adGroupCriterion->criterion->id = -1;

  $adGroupCriterion->biddingStrategyConfiguration = 
    $oldPartition->biddingStrategyConfiguration;
  $adGroupCriterion->criterionUse = "BIDDABLE";
  $adGroupCriterion->AdGroupCriterionType = "BiddableAdGroupCriterion";

  $operation = new AdGroupCriterionOperation();
  $operation->operand = $adGroupCriterion;
  $operation->operator = "ADD";

4) When I perform the mutation I get the error: PRODUCT_PARTITION_SUBDIVISION_REQUIRES_OTHERS_CASE

Many thanks,
Phil

Peter Oliquino

unread,
Aug 25, 2016, 4:32:52 AM8/25/16
to AdWords API Forum
Hi Phil,

You may review our shopping campaign guide and the slides. Every "subdivision" should always have an "Others" unit in addition to the units with specific criteria. You may see this In the AdWords UI as the "Everything else in...." entry. If you require more information on how to create an "Other" node, kindly refer to this forum thread.

If you continue to experience this error, kindly send your code snippet of the product partition you're trying to copy so I can take a better look at the issue.

Thanks and regards,
Peter
AdWords API Team

ph...@brainlabsdigital.com

unread,
Aug 25, 2016, 4:37:21 AM8/25/16
to AdWords API Forum
Hi Peter,

Thanks for the response. I understand this, but I thought by taking the existing partition from a previous ad group I would be able to re-apply this same partition to my ad group, hopefully keeping the partition structure in tact.

Can you confirm whether or not this is possible?

Thanks,
Phil

Peter Oliquino

unread,
Aug 25, 2016, 6:08:27 AM8/25/16
to AdWords API Forum
Hi Phil,

I believe you could do it through normal get and mutate operations. Could you confirm if the information you are getting from the original partition are correct and complete? It should basically follow the idea of creating a new partition. Also the error suggests that the "Others" scenario could be the primary cause. Could you confirm as well if the issue still persists after checking the existing partition is being retrieved correctly with the other node?

ph...@brainlabsdigital.com

unread,
Aug 25, 2016, 6:18:33 AM8/25/16
to AdWords API Forum
Hmm, I compared the Partition Object I received and the one I sent off and they appear identical.

I am only taking the root Product Partition though... should I be taking all product partitions from adgroupA, changing their adgroupIds to that of my target adgroup, then assign temporary ids?

Thanks,
Phil

Peter Oliquino

unread,
Aug 25, 2016, 6:32:34 AM8/25/16
to AdWords API Forum
Hi Phil,

Yes, and you should assign temporary IDs as well and that it should basically follow how you create a new partition as discussed in our guide.

Regards,
Peter
AdWords API Team

ph...@brainlabsdigital.com

unread,
Aug 25, 2016, 4:35:39 PM8/25/16
to AdWords API Forum
Hi Peter, 

Thank you for this, it has been very helpful.I have followed the guide and have made some progress.

I have now hit the following issue:
I send off my operations array containing 3 operations: [The root, a unit, and a negativeAdGroupCriterion unit].
This gives me the error of:
     AdGroupCriterionError.PRODUCT_PARTITION_ALREADY_EXISTS @ operations[2].operand.criterion

If I run with just the root and the negative, it succeeds but I have nothing in my product group (obviously)
Running without the negative fails with PRODUCT_PARTITION_SUBDIVISION_REQUIRES_OTHERS_CASE.

I hope you can point me in the right direction.

Here is my operations array. Maybe that will shed some light on the situation. 

Again, help much appreciated!

 [0] => AdGroupCriterionOperation Object
     (
         [operand] => BiddableAdGroupCriterion Object
             (
                 [userStatus] =>
                 [systemServingStatus] =>
                 [approvalStatus] =>
                 [disapprovalReasons] =>
                 [destinationUrl] =>
                 [experimentData] =>
                 [firstPageCpc] =>
                 [topOfPageCpc] =>
                 [firstPositionCpc] =>
                 [qualityInfo] =>
                 [biddingStrategyConfiguration] =>
                 [bidModifier] =>
                 [finalUrls] =>
                 [finalMobileUrls] =>
                 [finalAppUrls] =>
                 [trackingUrlTemplate] =>
                 [urlCustomParameters] =>
                 [adGroupId] => 36380370201
                 [criterionUse] =>
                 [criterion] => ProductPartition Object
                     (
                         [partitionType] => SUBDIVISION
                         [parentCriterionId] =>
                         [caseValue] =>
                         [id] => -1
                         [type] =>
                         [CriterionType] =>
                         [_parameterMap:Criterion:private] => Array
                             (
                                 [Criterion.Type] => CriterionType
                             )

                     )

                 [labels] =>
                 [forwardCompatibilityMap] =>
                 [baseCampaignId] =>
                 [baseAdGroupId] =>
                 [AdGroupCriterionType] =>
                 [_parameterMap:AdGroupCriterion:private] => Array
                     (
                         [AdGroupCriterion.Type] => AdGroupCriterionType
                     )

             )

         [exemptionRequests] =>
         [operator] => ADD
         [OperationType] =>
         [_parameterMap:Operation:private] => Array
             (
                 [Operation.Type] => OperationType
             )

     )

 [1] => AdGroupCriterionOperation Object
     (
         [operand] => BiddableAdGroupCriterion Object
             (
                 [userStatus] =>
                 [systemServingStatus] =>
                 [approvalStatus] =>
                 [disapprovalReasons] =>
                 [destinationUrl] =>
                 [experimentData] =>
                 [firstPageCpc] =>
                 [topOfPageCpc] =>
                 [firstPositionCpc] =>
                 [qualityInfo] =>
                 [biddingStrategyConfiguration] => BiddingStrategyConfiguration Object
                     (
                         [biddingStrategyId] =>
                         [biddingStrategyName] =>
                         [biddingStrategyType] =>
                         [biddingStrategySource] =>
                         [biddingScheme] =>
                         [bids] => Array
                             (
                                 [0] => CpcBid Object
                                     (
                                         [bid] => Money Object
                                             (
                                                 [microAmount] => 250000
                                                 [ComparableValueType] =>
                                                 [_parameterMap:ComparableValue:private]
                                                     (
                                                         [ComparableValue.Type] => Compar
                                                     )

                                             )

                                         [cpcBidSource] =>
                                         [BidsType] =>
                                         [_parameterMap:Bids:private] => Array
                                             (
                                                 [Bids.Type] => BidsType
                                             )

                                     )

                             )

                     )

                 [bidModifier] =>
                 [finalUrls] =>
                 [finalMobileUrls] =>
                 [finalAppUrls] =>
                 [trackingUrlTemplate] =>
                 [urlCustomParameters] =>
                 [adGroupId] => 36380370201
                 [criterionUse] =>
                 [criterion] => ProductPartition Object
                     (
                         [partitionType] => UNIT
                         [parentCriterionId] => -1
                         [caseValue] => ProductOfferId Object
                             (
                                 [value] =>
                                 [ProductDimensionType] => ProductOfferId
                                 [_parameterMap:ProductDimension:private] => Array
                                     (
                                         [ProductDimension.Type] => ProductDimensionType
                                     )

                             )

                         [id] =>
                         [type] =>
                         [CriterionType] =>
                         [_parameterMap:Criterion:private] => Array
                             (
                                 [Criterion.Type] => CriterionType
                             )

                     )

                 [labels] =>
                 [forwardCompatibilityMap] =>
                 [baseCampaignId] =>
                 [baseAdGroupId] =>
                 [AdGroupCriterionType] =>
                 [_parameterMap:AdGroupCriterion:private] => Array
                     (
                         [AdGroupCriterion.Type] => AdGroupCriterionType
                     )

             )

         [exemptionRequests] =>
         [operator] => ADD
         [OperationType] =>
         [_parameterMap:Operation:private] => Array
             (
                 [Operation.Type] => OperationType
             )

     )

 [2] => AdGroupCriterionOperation Object
     (
         [operand] => NegativeAdGroupCriterion Object
             (
                 [adGroupId] => 36380370201
                 [criterionUse] =>
                 [criterion] => ProductPartition Object
                     (
                         [partitionType] => UNIT
                         [parentCriterionId] => -1
                         [caseValue] => ProductOfferId Object
                             (
                                 [value] =>
                                 [ProductDimensionType] => ProductOfferId
                                 [_parameterMap:ProductDimension:private] => Array
                                     (
                                         [ProductDimension.Type] => ProductDimensionType
                                     )

                             )

                         [id] =>
                         [type] =>
                         [CriterionType] =>
                         [_parameterMap:Criterion:private] => Array
                             (
                                 [Criterion.Type] => CriterionType
                             )

                     )

                 [labels] =>
                 [forwardCompatibilityMap] =>
                 [baseCampaignId] =>
                 [baseAdGroupId] =>
                 [AdGroupCriterionType] =>
                 [_parameterMap:AdGroupCriterion:private] => Array
                     (
                         [AdGroupCriterion.Type] => AdGroupCriterionType
                     )

             )

         [exemptionRequests] =>
         [operator] => ADD
         [OperationType] =>
         [_parameterMap:Operation:private] => Array
             (
                 [Operation.Type] => OperationType
             )

     )

Peter Oliquino

unread,
Aug 25, 2016, 11:12:39 PM8/25/16
to AdWords API Forum
Hi Phil,

The PRODUCT_PARTITION_ALREADY_EXISTS error suggests that the partition can no longer be added to the AdGroup because it already exists. I noticed in the operand[2] ( [2] => AdGroupCriterionOperation Object ) you are using the same temporary ID ([parentCriterionId] => -1). Could you try assigning a different value instead? Although they are temporary, these IDs also need to be distinct when used in a single request.

Best regards,
Peter
AdWords API Team

ph...@brainlabsdigital.com

unread,
Aug 26, 2016, 5:36:32 AM8/26/16
to AdWords API Forum
Hi Peter,

After changing the id to -2 I get:
AdGroupCriterionError.PRODUCT_PARTITION_DOES_NOT_EXIST @ operations[2].operand.criterion.parentCriterionId; trigger:'TempCriterionId{id=2}'

Similarly for if I change the id of [1] to -2 instead. 

Phil

ph...@brainlabsdigital.com

unread,
Aug 26, 2016, 6:25:43 AM8/26/16
to AdWords API Forum
Also just to add: I think the documentation says these nodes should have the parentCriterion ids the same as the root->id ?


ProductPartition root = new ProductPartition();
root
.setPartitionType(ProductPartitionType.SUBDIVISION);
root
.setId(-1);

ProductPartition node1 = new ProductPartition();
node1
.setPartitionType(ProductPartitionType.UNIT);
node1
.setCaseValue(new ProductBrand(null, "Brand A"));
node1
.setParentCriterionId(root.getId());
ProductPartition node2 = new ProductPartition();
node2
.setPartitionType(ProductPartitionType.UNIT);
node2
.setCaseValue(new ProductBrand());
node2
.setParentCriterionId(root.getId());

https://developers.google.com/adwords/api/docs/guides/shopping
ProductPartition node2 = new ProductPartition();
node2
.setPartitionType(ProductPartitionType.UNIT);
node2
.setCaseValue(new ProductBrand());
node2
.setParentCriterionId(root.getId());

ph...@brainlabsdigital.com

unread,
Aug 26, 2016, 11:07:52 AM8/26/16
to AdWords API Forum

Found the issue:

My partition case value was missing a value. In removing it for the negative value I also removed it for the partition.

For reference, the parent ids should all be -1 in this case (although this is a flat structure)

Thanks again Peter
Reply all
Reply to author
Forward
0 new messages