Create new keyword and add label

61 views
Skip to first unread message

Anis Ahmed

unread,
Aug 8, 2023, 5:29:46 AM8/8/23
to Google Ads API and AdWords API Forum
Hi Google Team,

Is there a way that I can create a new keyword and give it a label in 1 mutate operation?
Currently I see that AdGroupCriterion is used for creating the keyword and AdGroupCriterionLabelService is used to add the label to the keyword,

Is it possible to do it in 1 operation when creating the AdGroupCriterion?
Thanks

Google Ads API Forum Advisor

unread,
Aug 8, 2023, 10:20:07 AM8/8/23
to aniska...@gmail.com, adwor...@googlegroups.com

Hi,

Thanks for reaching out to the Google Ads API Forum.

With regards to your concern, you may refer to this service (https://developers.google.com/google-ads/api/reference/rpc/v14/GoogleAdsService#mutate), this method supports atomic transactions with multiple types of resources. For example, you can atomically create a campaign and a campaign budget, or perform up to thousands of mutates atomically. Then, you may check this reference (https://developers.google.com/google-ads/api/reference/rpc/v14/MutateOperation) for the list of operations to perform on individual resources. You may try this on your end and please let us know how it goes. 

This message is in relation to case "ref:_00D1U1174p._5004Q2ncszV:ref"

Thanks,
 
Google Logo Google Ads API Team


Anis Ahmed

unread,
Aug 8, 2023, 10:46:27 AM8/8/23
to Google Ads API Forum Advisor, adwor...@googlegroups.com
Hi, 
Thanks for your reply. I had a look and I don't think we can still use this MutateGoogleAdsRequest as I need to perform these operations together : Create AdGroupCirterion and create AdGroupCirterionLabel.
Since the AdGroupCriterionLabel requires the resourceName for AdGroupCriterion, I can't use it in an atomic way. First I need to create AdGroupCriterion separately and once I have the resourceName I can create the label.

I wanted to do these 2 operations together such that the keyword is always created with the label and it's not done separately as it can cause partial errors and we'll have to handle them separately.

Google Ads API Forum Advisor

unread,
Aug 8, 2023, 1:02:58 PM8/8/23
to aniska...@gmail.com, adwor...@googlegroups.com

Hi,

Thanks for getting back with us.

With regards to your concern, you may refer to the customers.googleAds.mutate to perform the following implementation simultaneously. You may also use the API explorer to build and validate your request. 

Additionally, you may need to use the labelOperation first, then the adGroupCriterionOperation, lastly adGroupCriterionLabelOperation. For the resource name you may use a temp id to perform the operations with the negative sign in front of the id. For example "resourceName": "customers/{customer_id}/labels/-1".  You may use the endpoint below in your HTTP request URI to send the said request.

https://googleads.googleapis.com/v14/customers/{customerId}/googleAds:mutate 

You may also refer to the sample request provided below:

{
  "mutateOperations": [
    {
      "labelOperation": {
        "create": {
          "name": "<insert text here>",
          "resourceName": "customers/{customer_id}/labels/-1"
        }
      }
    },
    {
      "adGroupCriterionOperation": {
        "create": {
          "keyword": {
            "matchType": "<please refer to the enums here: https://developers.google.com/google-ads/api/rest/reference/rest/v14/KeywordMatchType>",
            "text": "<insert text here>"
          },
          "resourceName": "customers/{customer_id}/adGroupCriteria/{adgroup_id}~-2"
        }
      }
    },
    {
      "adGroupCriterionLabelOperation": {
        "create": {
          "label": "customers/{customer_id}/labels/-1",
          "adGroupCriterion": "customers/{customer_id}/adGroupCriteria/{adgroup_id}~-2"
        }
      }
    }
  ]
}

Let me know how this goes on your end.

Links included in this email:

Reply all
Reply to author
Forward
0 new messages