Google Ads API: Create sitelink and association as 1 atomic operation

44 views
Skip to first unread message

Ales Sturala

unread,
Oct 13, 2020, 4:16:33 AM10/13/20
to AdWords API and Google Ads API Forum
Hello,
to my understanding, GoogleAdsService is there to perform atomic operations across different entities/services, such as campaign+buget. We have tried to create sitelink+association in 1 atomic operation using the same API but it doesn't work, failing on an error that says that we cannot set ResourceName on SitelinkFeedItem when in CREATE operation.

Is it possible to create sitelinks and an association in 1 submit? It would be a perfect use case for GoogleAdsService.

This is our code (C#):

var adGroupResourceName = CreateAdGroup(campaignResourceName, $"{sitelinkPrefix}{i}");

var extensionFeedItemOperation = new GoogleV5Services.MutateOperation()
                {
                    ExtensionFeedItemOperation = new GoogleV5Services.ExtensionFeedItemOperation()
                    {
                        Create = new GoogleV5Resources.ExtensionFeedItem()
                        {
                            // Create your sitelinks.
                            SitelinkFeedItem = new GoogleV5Common.SitelinkFeedItem()
                            {
                                LinkText = $"{sitelinkPrefix}{i}_1",
                                FinalUrls = { $"{url}{i}_1" },
                            },
                            ResourceName = $"customers/{customerId}/extensionFeedItems/-1",
                        }
                    }
                };

var adGroupExtensionSetting = new GoogleV5Resources.AdGroupExtensionSetting()
                {
                    AdGroup = adGroupResourceName,
                    ExtensionType = GoogleV5Enums.ExtensionTypeEnum.Types.ExtensionType.Sitelink,
                    ExtensionFeedItems = { $"customers/{customerId}/extensionFeedItems/-1" }
                };

                var adGroupExtensionSettingOperation = new GoogleV5Services.MutateOperation()
                {
                    AdGroupExtensionSettingOperation = new GoogleV5Services.AdGroupExtensionSettingOperation()
                    {
                        Create = adGroupExtensionSetting,
                    }
                };

var results = service.Mutate(customerId, new[] { extensionFeedItemOperation,  adGroupExtensionSettingOperation }).MutateOperationResponses.ToArray();    

Google Ads API Forum Advisor Prod

unread,
Oct 13, 2020, 2:56:34 PM10/13/20
to al...@trueclicks.com, adwor...@googlegroups.com
Hi Ales,

You will need to create the sitelink first before associating it with a campaign, similar to how it's described here.

Regards,
Anthony
Google Ads API Team

Google Logo
Anthony
Google Ads API Team
 


ref:_00D1U1174p._5004Q268nES:ref
Reply all
Reply to author
Forward
0 new messages