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