Hi Team,
I referred to the 
document: 
https://developers.google.com/google-ads/api/docs/samples/update-campaign-criterion-bid-modifier
 

Below is my code to opt out some Tablet and Desktop from Display Campaign

from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.errors import GoogleAdsException
from google.api_core import protobuf_helpers

campaign_criterion_service = 
src_client.get_service("CampaignCriterionService")
ops = []
criterion_id_list = ['30000', '30002']
for criterion_id in criterion_id_list:
    criterion_rname = campaign_criterion_service.campaign_criterion_path(
        src_customer_id, src_campaign_id, criterion_id
    )
    print(f"criterion_rname={criterion_rname}")
    campaign_criterion_operation = 
src_client.get_type("CampaignCriterionOperation")
    campaign_criterion = campaign_criterion_operation.update
    campaign_criterion.resource_name = criterion_rname
    campaign_criterion.bid_modifier = 0.0       # 设置为0.0 进行排除
    src_client.copy_from(
        campaign_criterion_operation.update_mask,
        protobuf_helpers.field_mask(None, campaign_criterion._pb),
    )
    ops.append(campaign_criterion_operation)

result_res_names = []
for row in campaign_criterion_service.mutate_campaign_criteria(
        customer_id=src_customer_id, operations=ops
).results:
    print(
        "Update Campaign Criteria with resource name: "
        f'"{row.resource_name}".'
    )
    result_res_names.append(row.resource_name)


Script run without error message, but it does not work. From UI, the device 
part does not opt out Desktop and Tablet as below screenshot.
[image: error-sample-2022-11-17.png]

I query with SQL as below, the bid value is not 0.0 as expected
query = f"""
select 
    campaign.id,
    campaign_criterion.resource_name,
    campaign_criterion.type,
    campaign_criterion.status,
    campaign_criterion.criterion_id,
    campaign_criterion.bid_modifier,
    campaign_criterion.display_name,
    campaign_criterion.negative
from campaign_criterion 
WHERE campaign.id = {src_campaign_id}
      and campaign_criterion.type = DEVICE
"""

I made a sample request and log as below. please help with this.
2022-11-17 09:01:23,095 [INFO] logging_interceptor.py@228 - 
log_successful_request(): Request made: ClientCustomerId: xxxxxx, Host: 
googleads.googleapis.com, Method: 
/google.ads.googleads.v11.services.CampaignCriterionService/MutateCampaignCriteria,
 
RequestId: *MCjVF87FC6PjR08Zc0Gkzw*, IsFault: False, FaultMessage: None

customer id is replaced with xxxxx


Thanks!
Wenjun

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/46cd5119-ca5f-41e7-ba99-9400806c8d6fn%40googlegroups.com.

Reply via email to