The code below works fine only when assigning a single conversion.
It does not work for multiple as it was told above and also it does not 
work in conversion action set is already assigned via UI.
BTW,  AdWords API was better in terms of giving specific errors for such 
cases.

It would be interesting to see:
1) some compact code that sets conversion action set via SOAP API, not 
using Java wrapper in case it does not support it
2) an approximate date (if it is already planned) when it is planned for 
support in Java API

private void runExample(GoogleAdsClient googleAdsClient, long customerId) {
//List<Long> conversionIds = Arrays.asList(526204302L, 527630287L, 
527627998L);

List<Long> conversionIds = Arrays.asList(526204302L);

Campaign campaign =
Campaign.newBuilder()
//.setResourceName(ResourceNames.campaign(customerId, 11002617728L)) 
//11002617728 - search, 11662629026L - display
.setResourceName(ResourceNames.campaign(customerId, 11662629026L)) 
//11002617728 - search, 11662629026L - display
.setSelectiveOptimization(Campaign.SelectiveOptimization.newBuilder()
.addAllConversionActions(
conversionIds.stream().map(
c -> ResourceNames.conversionAction(customerId, c)
).collect(toList())
)
.build())
.build();

// Creates the operation.
CampaignOperation op = CampaignOperation.newBuilder()
.setUpdate(campaign)
.setUpdateMask(FieldMasks. allSetFieldsOf(campaign))
.build();
try (CampaignServiceClient campaignServiceClient =
googleAdsClient.getLatestVersion().createCampaignServiceClient())
{
MutateCampaignsResponse response =
campaignServiceClient.mutateCampaigns(
Long.toString(customerId), Collections.singletonList(op));
System.out.printf("Added %d conversion actions:%n", 
response.getResultsCount());
for (MutateCampaignResult result : response.getResultsList()) {
System.out.printf(
"New conversion action added with resource name: '%s'%n", 
result.getResourceName());
}
}
}

On Wednesday, April 14, 2021 at 4:46:54 AM UTC+3 adsapiforumadvisor wrote:

> Hi,
>
> Thank you for reaching out. However, I had to delete your initial post as 
> it contained your logs.
>
> Regarding your question :
>
>
>
>
>
>
>
>
>
>
> *Is there documentation describing if campaign can or cannot have 
> selective optimization on multiple conversion actions? For example, in UI I 
> can assign either single conversion action (CA) or conversion action set 
> (CAS). However, I can read via API only data with single CA: 
> SELECT campaign.id <http://campaign.id/>, 
> campaign.selective_optimization.conversion_actions FROM campaign; For 
> campaigns with CAS this field is empty so there should be another one. 
> Please describe how to manage CAS with API and assign it in certain 
> campaign selective optimization. Currently even single CA assignment via 
> API does not work for me:*
>
> A conversion action can be specified in the selective optimization 
> attribute for you app campaigns, as seen in this guide 
> <https://developers.google.com/google-ads/api/docs/app-campaigns/create-campaign?hl=en#preparation>.
>  
> However, *conversion action sets* are currently not supported in the 
> Google Ads API and therefore cannot be managed and could be the reason why 
> they are not visible in the report.
>
> Best regards,
>
> [image: Google Logo] 
> Peter Laurence Napa Oliquino 
> Google Ads API Team 
>   
>
> ref:_00D1U1174p._5004Q2FY4PC:ref
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 
"AdWords API and Google Ads 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/a261435b-9e2f-4a66-8819-3601b7b3aa15n%40googlegroups.com.

Reply via email to