How to paused keywords with Google Ads API and python

483 views
Skip to first unread message

Data DataSem

unread,
Jan 3, 2020, 12:06:04 AM1/3/20
to AdWords API and Google Ads API Forum
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)

Google Ads API Forum Advisor Prod

unread,
Jan 3, 2020, 11:43:29 AM1/3/20
to da...@datasem.net, adwor...@googlegroups.com
Hi,

Thank you for reaching out. In order to pause a keyword, you can follow the example you posted however instead of updating the bidding strategy, you should update the userStatus to PAUSED. This must be done at the ad group level so if you would only like it to apply to a single ad, you should create a separate ad group with just that ad and the keywords you desire.

Regards,
Mitchell
Google Ads API Team

ref:_00D1U1174p._5001UOFkQ3:ref

Data DataSem

unread,
Jan 4, 2020, 12:58:53 PM1/4/20
to AdWords API and Google Ads API Forum
Hey... thanks for the answer... was exactly what I was looking for.  
Reply all
Reply to author
Forward
0 new messages