Changing campaign targeting settings through Google Ads API: immutable fields

76 views
Skip to first unread message

Ernst Kuiper

unread,
Apr 2, 2019, 3:40:09 PM4/2/19
to AdWords API and Google Ads API Forum
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 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

googleadsapi...@google.com

unread,
Apr 2, 2019, 5:29:11 PM4/2/19
to AdWords API and Google Ads API Forum
Hello Ernst, 

This is a known issue and our team is looking into this. I will keep you posted on our findings.

Thanks,
Bharani, Google Ads API Team

googleadsapi...@google.com

unread,
Apr 9, 2019, 10:41:48 AM4/9/19
to eku...@bol.com, AdWords API and Google Ads API Forum
Hello Ernst, 

The fix went live yesterday. Please try your request again and let me know if you still encounter issues with the updates.
Reply all
Reply to author
Forward
0 new messages