Operations on different kinds of entities in a single request

74 views
Skip to first unread message

Vitaly Dukhota

unread,
Mar 26, 2019, 1:48:46 PM3/26/19
to AdWords API and Google Ads API Forum
Hi,

I know it's possible to mutate multiple entities of the same kind in a single request, and the operations will be done atomically (all or none). For example, it's possible to create multiple campaign operations and submit them all in a single atomic request, but the problem is that they all have to be of the same kind (only campaign operations for the example). I also know that it's possible to create a batch operation with can mutate entities of different kinds (for example, both campaigns and ad groups) in a (kind of) single request. The problem with batch operations is that they are not atomic - some operations might fail whilst others will be completed.

My question is: is it possible to create entities of different kinds in a single atomic operation? For example, I want to create a complete hierarchy of entities (budget-campaigns-ad groups-ads-keywords) for a newly created managed account. Is it possible to create the hierarchy atomically?

Thanks in advance.

googleadsapi...@google.com

unread,
Mar 26, 2019, 5:00:37 PM3/26/19
to AdWords API and Google Ads API Forum
Hi,

Your understanding is correct. It is not possible to do that using the AdWords API. Batch job is the only available option if you would like to perform operations on multiple type of objects.

Thanks,
Sreelakshmi, Google Ads API Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/

Vitaly Dukhota

unread,
Mar 27, 2019, 10:01:20 AM3/27/19
to AdWords API and Google Ads API Forum
Thank you Sreelakshmi. Am I right assuming your answer applies to both AdWords API and the new Ads API?

googleadsapi...@google.com

unread,
Mar 27, 2019, 3:41:11 PM3/27/19
to AdWords API and Google Ads API Forum
Hi, 

Yes, the same applies for Google Ads API. You will only be able to batch same kind of operation on the same type on entities in one request. Please read more about operations and batching them here

Thanks,
Sreelakshmi, Google Ads API Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Van Vu

unread,
May 4, 2019, 10:38:30 PM5/4/19
to AdWords API and Google Ads API Forum
Hi Vitaly,
I joined the GoogleAds workshop recently and tried to do exactly what you want: create a complete hierarchy of entities (budget-campaigns-ad groups-ads-keywords) for a newly created managed account

My answer is Yes, you can create the complete Campaign hierarchy in one operation. Below is what I found:

1- Order of the operation that you put into List<MutateOperation> is important: CampaignBudgetOperation --> CampaignOperation --> AdGroupOperation --> AdGroupAdOperation --> AdGroupCriterionOperation
2- Use different temporary Ids for new resource:
    CampaignBudget resourcename = customers/12345/campaignBudgets/ -1 
    Campaign resourcename = customers/12345/campaigns/ -2
    AgGroup resourcename = customers/12345/adGroups/ -3

Below is the pseudo code in .NET but you'll get the idea:

var googleAdsService = client.GetService(Google.Ads.GoogleAds.Services.V1.GoogleAdsService);
googleAdsService.Mutate(googleAdsId, new List<MutateOperation>
                    {
                        new MutateOperation
                        {
                            CampaignBudgetOperation = new CampaignBudgetOperation
                            {
                                Create = new CampaignBudget {  ResourceName = "customers/12345/campaignBudgets/-1", ... }
                            },
                        new MutateOperation
                        {
                            CampaignOperation = new CampaignOperation
                            {
                                Create = new Campaign { ResourceName = "customers/12345/campaigns/ -2", CampaignBudget = "customers/12345/campaignBudgets/-1" }
                            }
                        },
                        new MutateOperation
                        {
                            AdGroupOperation = new Google.Ads.GoogleAds.V1.Services.AdGroupOperation
                            {
                                Create = new AdGroup { ResourceName = "customers/12345/adGroups/ -3", Campaign =  "customers/12345/campaigns/ -2" }
                            }
                        },
                        new MutateOperation
                        {
                            AdGroupAdOperation = new Google.Ads.GoogleAds.V1.Services.AdGroupAdOperation
                            {
                                Create = new AdGroupAd { ResourceName = [not required], AdGroup =  "customers/12345/adGroups/ -3" }
                            }
                        },
                        new MutateOperation
                        {
                            AdGroupCriterionOperation = new Google.Ads.GoogleAds.V1.Services.AdGroupCriterionOperation
                            {
                                Create = new AdGroupCriterion { ResourceName = [not required], AdGroup =  "customers/12345/adGroups/ -3}
                            }
                        }
                    });


Hope this helps

Vitaly Dukhota

unread,
May 9, 2019, 8:38:17 AM5/9/19
to AdWords API and Google Ads API Forum
Thank you so much Van Vu for taking time to post this! This is a really cool find. I will surely try this approach - ability to create the whole hierarchy atomically is priceless for my purposes.
Reply all
Reply to author
Forward
0 new messages