Hi,

recently I visited a Google Ads API workshop in London where I asked 
whether it was possible to change the targeting setting of a campaign using 
the Google Ads API from 'Bid Only' to 'Target and Bid' or vice versa. We 
want to automate this because when adding a user list to a campaign using 
the API, the targeting setting of the campaign immediately defaults to 
'Target and Bid' which we do not want. I was told it should be possible and 
I should look at the campaign.targeting_setting.target_restrictions. 
I managed to figure out how to create the update operator, however when I 
do mutate_campaigns with my list of operations I get an error stating that 
*"Field 
\'targeting_setting.target_restrictions\' cannot be modified by \'UPDATE\' 
operation"*

Since the documentation 
<https://developers.google.com/google-ads/api/docs/fields/campaign> does 
not state that the campaign.targeting_setting.target_restrictions field is 
immutable I am wondering what is going on. Am I doing something wrong here? 
Or is the field indeed immutable through the API? 
The way I construct the operation is given below. Any help would be greatly 
appreciated.

# Initialize campaign criterion operation and user list resource
campaign_service = account_client.get_service('CampaignService', version=
'v1')
campaign_operation = account_client.get_type('CampaignOperation', version=
'v1')
targeting_setting = account_client.get_type('TargetingSetting', version='v1'
)
target_restrictions = account_client.get_type('TargetRestriction', version=
'v1')
targeting_dimension = account_client.get_type('TargetingDimensionEnum', 
version='v1')

# Prepare the target_restrictions
target_restrictions.targeting_dimension = targeting_dimension.AUDIENCE
target_restrictions.bid_only.value = False

targeting_setting.target_restrictions.extend([target_restrictions])

# Create the operation and fill in campaign
campaign_update = campaign_operation.update
campaign_update.resource_name = campaign_service.campaign_path(account_id, 
campaign_id)
campaign_update.targeting_setting.CopyFrom(targeting_setting)

# Retrieve a FieldMask for the fields configured in the campaign.
fm = protobuf_helpers.field_mask(None, campaign_update)
campaign_operation.update_mask.CopyFrom(fm)

Cheers and thanks.

Ernst

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/a838bdca-bc33-4e71-a151-d7d5d2f215a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • Changin... 'Ernst Kuiper' via AdWords API and Google Ads API Forum
    • RE... googleadsapi-forumadvisor via AdWords API and Google Ads API Forum
    • RE... googleadsapi-forumadvisor via AdWords API and Google Ads API Forum

Reply via email to