I was trying to change the status of keyword from enable to paused in googles ads using the API. I found the following documentation however it only mention how to update a the bid for the keyword
however I need something to paused a keyword within an AdGroupAd... is there any sample example or way to do that. Thanks in advance
from googleads import adwords
AD_GROUP_ID = 'INSERT_AD_GROUP_ID_HERE'
CRITERION_ID = 'INSERT_KEYWORD_CRITERION_ID_HERE'
def main(client, ad_group_id, criterion_id):
# Initialize appropriate service.
ad_group_criterion_service = client.GetService(
'AdGroupCriterionService', version='v201809')
# Construct operations and update bids.
operations = [{
'operator': 'SET',
'operand': {
'xsi_type': 'BiddableAdGroupCriterion',
'adGroupId': ad_group_id,
'criterion': {
'id': criterion_id,
},
'biddingStrategyConfiguration': {
'bids': [
{
'xsi_type': 'CpcBid',
'bid': {
'microAmount': '1000000'
}
}
]
}
}
}]
ad_group_criteria = ad_group_criterion_service.mutate(operations)
# Display results.
if 'value' in ad_group_criteria:
for criterion in ad_group_criteria['value']:
if criterion['criterion']['Criterion.Type'] == 'Keyword':
print('Ad group criterion with ad group id "%s" and criterion id '
'"%s" currently has bids:'
% (criterion['adGroupId'], criterion['criterion']['id']))
for bid in criterion['biddingStrategyConfiguration']['bids']:
print('\tType: "%s", value: %s' % (bid['Bids.Type'],)
bid['bid']['microAmount'])
else:
print('No ad group criteria were updated.')
if __name__ == '__main__':
# Initialize client object.
adwords_client = adwords.AdWordsClient.LoadFromStorage()
main(adwords_client, AD_GROUP_ID, CRITERION_ID)