What is the expected method for sharing sitelinks across campaigns using the Campaign Extension Setting service?

349 views
Skip to first unread message

Alexander Cavalli

unread,
Sep 9, 2015, 2:20:30 PM9/9/15
to AdWords API Forum
I need to build a service that uses the Adwords API to manage sitelinks that can be shared across multiple campaigns. I've previously used the various Feed services to handle this, but I noticed there are newer Extension Setting services that simplify the mapping process for the standard matching function. However, from what I've been able to find, the guides don't mention anything about using the same sitelinks (or other extensions) across multiple campaigns. Is this something that can be achieved using the Extension Setting services? It seems like one approach would be something like this:
  1. ADD the sitelinks to the first campaign.
  2. Parse the sitelinks out of the return value of the add operation (to get their ids) and use the SET operator on any other campaigns.
It's a bit confusing though, since the initial ADD operation is being used to both create the sitelinks and do the mapping. Is there a more straightforward approach (that still doesn't require the use of FeedItems and the like)? Something like this:
  1. Create the sitelinks without mapping them to any campaigns.
  2. Using the returned info (sitelinks with ids), use the SET operator with the Campaign Extension Service to create the mappings.
I don't see any way of achieving step 1 outside of using the Feed services, but I thought I would ask in case I overlooked something.

Thanks,
- Alex

Umesh Dengale

unread,
Sep 9, 2015, 5:21:35 PM9/9/15
to AdWords API Forum
Hi Alex,

You could use the CustomerExtensionSettingService to set extensions at the customer level. Please check out our Extension Setting Services guide for more details.

Cheers,
Umesh, AdWords API Team.

Alexander Cavalli

unread,
Sep 10, 2015, 5:08:03 PM9/10/15
to AdWords API Forum
Thanks Umesh. Wouldn't that apply the sitelinks to all campaigns in the account? If so, is there a way to set the sitelinks for only specific campaigns, rather than account-wide?

Umesh Dengale

unread,
Sep 10, 2015, 5:45:13 PM9/10/15
to AdWords API Forum
Hi Alex,

Yes, you are correct. The CustomerExtensionSettingService will apply the sitelinks to all campaigns in the account. You could use the CampaignExtensionSettingService to add the sitelinks to specific campaigns.  You could create the CampaignExtensionSettingOperation for an individual campaign and pass these CampaignExtensionSettingOperation objects (Campaigns you want to add the sitelinks) to an array as input to the CampaignExtensionSettingService.mutate operation.

Thanks,
Umesh, AdWords API Team.

Alexander Cavalli

unread,
Sep 14, 2015, 10:13:37 AM9/14/15
to AdWords API Forum
Hi Umesh,

Thanks for the suggestion, that was what I was originally considering doing. But it seems like that will make different sitelinks across the campaigns, unless I use sitelinks that already exist (i.e. ones that I have the Adwords IDs for) and the SET operation within mutate. I'd like to share the sitelinks across the multiple campaigns, since they will actually be the same sitelinks (and I'd rather not store a mapping between the unified sitelink on my end on the many different sitelinks on the Adwords end). It sounds like in order to do this with the ExtensionSetting services I'd have to go with the approach I originally suggested: ADD to one campaign (to get the IDs), and then SET on the remaining campaigns. If that's the case, that's fine, I was just wondering if there was some way to separate the implicit creation of the sitelinks happening on the ADD step from the campaign-sitelink mapping happening on both the ADD and SET steps. 

Thanks again for the help,
- Alex

Nadine Sundquist (AdWords API Team)

unread,
Sep 14, 2015, 7:51:25 PM9/14/15
to AdWords API Forum
Hi Alex,

For Extension Settings Services, we don't separate the process of creating the site link from attaching it to a campaign. It's all done in one mutate call. We still have the feed services option because there are a few cases where it could be useful to use feeds.

Each of our client libraries have examples on creating site links. Here's an AddSiteLinks example in Java, if you want to take a look. You'll want to add a CampaignExtensionSetting with your associated SiteLinkFeedItems for each campaign.

Best,
Nadine, AdWords API Team

Alexander Cavalli

unread,
Sep 15, 2015, 11:13:55 AM9/15/15
to AdWords API Forum
Hi Nadine,

Thanks for the info. I've looked at the examples and the documentation, and while they are very clear for the simple case (each campaign has a separate set of sitelinks), it isn't clear to me what to do if I want to share the same sitelinks across multiple campaigns (similar to how the Shared Library works in the Adwords UI). 

It sounds like you are suggesting that I run the mutate "add" action to each campaign for some set of SiteLinkFeedItems using the CampaignExtensionSetting service. As you said, the mutate "add" operation both creates the sitelinks and creates the mappings. Because of that, I'm under the impression that running the mutate "add" operation on multiple campaigns with the same SiteLinkFeedItems (and specifically, new ones, i.e. without ids) would attempt to re-create the sitelinks, and I would either end up with duplicate copies of the sitelinks, or Adwords would reject the request because the sitelinks already exist. Is this the behavior? Or does the API figure out that it has received sitelinks that already exist, and uses the existing ones rather than trying to create more (despite not being provided IDs)?

I can do this with the old-style FeedItems already - the steps would be something like:
  1. Create the sitelinks using the FeedItem service and get the feed item ids from the response (1,2,3,4,5)
  2. Create a matching function for a campaign feed, something like "feed_item_id IN (1,2,3,4,5)".
  3. Create a CampaignFeed for each campaign id I want to map to using the matching function generated in step 2.
It sounds like, to do this with extension settings, you're suggesting something like this:
  1. Build an ExtensionSetting containing all the sitelinks I want to create and map.
  2. Build CampaignExtensionSettings using the ExtensionSetting from step 1 for each campaign id I want mapped.
  3. Build CampaignExtensionSettingOperations using the CampaignExtensionSettings from step 2 and the ADD operator. (this is the step I'm wondering about, specifically the ADD operator)
  4. Use the CampaignExtensionSettingService to push the array of operations from step 3 using the mutate call.
Intuitively to me this seems like it will fail, because the first operation in the array (built in step 3) will create the sitelinks, and the second and all future operations will try to create the sitelinks again and do something bad (either fail or make duplicates). If the API will handle this properly, please let me know. And thanks again for the help!
- Alex

Nadine Sundquist (AdWords API Team)

unread,
Sep 15, 2015, 1:56:03 PM9/15/15
to AdWords API Forum
Hi Alex,

Yes, you've got the process correct for extension settings. If you're anything like me (who thinks a piece of code is worth a thousand words), you'll probably appreciate this code example on migrating to extension settings. Existing site links through the FeedItemService can be migrated to extension settings while also cleaning up pre-existing feed items. If you're coding in another language, the other client libraries also have the same example. 

Glad to help,
Nadine, AdWords API Team

Alexander Cavalli

unread,
Sep 15, 2015, 2:07:21 PM9/15/15
to AdWords API Forum
Alright, thanks for the clarification and links! Much appreciated.

Clément Picou

unread,
Dec 22, 2015, 6:16:42 AM12/22/15
to AdWords API Forum
Because of that, I'm under the impression that running the mutate "add" operation on multiple campaigns with the same SiteLinkFeedItems (and specifically, new ones, i.e. without ids) would attempt to re-create the sitelinks, and I would either end up with duplicate copies of the sitelinks
Hello, it's not an impression. I've followed this process and I've got duplicate sitelinks. I really don't know how to avoid this. Maybe if you create only the CampaignExtensionSetting for the first campaign, then get the SitelinkFeedItem id in the response and for the others campaigns, set the id ?

Nadine Sundquist (AdWords API Team)

unread,
Dec 22, 2015, 10:22:30 AM12/22/15
to AdWords API Forum
Hi Clément,

Have you had a chance to check out our example on migrating to extension settings? That example shows a process that will help you avoid duplicates. If you find that you're still having issues after looking through that example, please click Reply privately to author and send either the SOAP XML logs of a case where you are getting duplicates or a snippet of code that you're using where you're getting duplicates.

Cheers,
Nadine, AdWords API Team
Message has been deleted

Albert Wang

unread,
Mar 29, 2016, 4:53:25 AM3/29/16
to AdWords API Forum
I think I am mis understanding  this thread a bit. 

so are you saying, sharing sitelink feed items cross campaigns are impossible because it is done in one mutate call ?  and if sharing is needed use the legacy API ?
this actually fits my original understanding toward the extension documentation. 

I've tried a few ways to share the sitelink feed items using extension service. 
- two extension in one call, -> useless different sitelink feed item id returned
- setting ids to the new sitelink item -> useless, different sitelink feed item id retruned.

Nadine Sundquist (AdWords API Team)

unread,
Mar 29, 2016, 2:33:52 PM3/29/16
to AdWords API Forum
Hi Albert,

I simplified the add sitelinks to a campaign example and gave this a try. I simplified it where I only did the first sitelink feed item with the Store Hours

Step 1: I called the CampaignExtensionSettingServices and added the my first site link to one campaign (in this case campaign ID 346166693). Here's the SOAP request and response:

[29 Mar 2016 13:56:42,285 - INFO ] Outgoing Request:
<SOAP-ENV:Body><mutate xmlns="https://adwords.google.com/api/adwords/cm/v201603"><operations><operator>ADD</operator><operand><campaignId>346166693</campaignId><extensionType>SITELINK</extensionType><extensionSetting><extensions xsi:type="SitelinkFeedItem" ><sitelinkText>Store Hours</sitelinkText><sitelinkFinalUrls><urls>http://www.example.com/storehours</urls></sitelinkFinalUrls></extensions></extensionSetting></operand></operations></mutate></SOAP-ENV:Body>
[29 Mar 2016 13:56:42,865 - INFO ] Incoming response:
<soap:Body><mutateResponse xmlns="https://adwords.google.com/api/adwords/cm/v201603"><rval><ListReturnValue.Type>CampaignExtensionSettingReturnValue</ListReturnValue.Type><value><campaignId>346166693</campaignId><extensionType>SITELINK</extensionType><extensionSetting><extensions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="SitelinkFeedItem"><feedId>26419921</feedId><feedItemId>3856853919</feedItemId><status>ENABLED</status><feedType>SITELINK</feedType><ExtensionFeedItem.Type>SitelinkFeedItem</ExtensionFeedItem.Type><sitelinkText>Store Hours</sitelinkText><sitelinkFinalUrls><urls>http://www.example.com/storehours</urls></sitelinkFinalUrls></extensions><platformRestrictions>NONE</platformRestrictions></extensionSetting></value></rval></mutateResponse></soap:Body>


Now I had an existing sitelink feed item ID: 3856853919

Step 2: Create another CampaignExtensionSetting for a different campaign (in this case 346505693). Reuse the feed item ID from earlier by setting that feed item ID (3856853919) as the only field set in the SiteLinkFeedItem.


[29 Mar 2016 14:03:01,170 - INFO ] Outgoing Request:
<SOAP-ENV:Body><mutate xmlns="https://adwords.google.com/api/adwords/cm/v201603"><operations><operator>ADD</operator><operand><campaignId>346505693</campaignId><extensionType>SITELINK</extensionType><extensionSetting><extensions xsi:type="SitelinkFeedItem" ><feedItemId>3856853919</feedItemId></extensions></extensionSetting></operand></operations></mutate></SOAP-ENV:Body>
[29 Mar 2016 14:03:01,500 - INFO ] Incoming response:
<soap:Body><mutateResponse xmlns="https://adwords.google.com/api/adwords/cm/v201603"><rval><ListReturnValue.Type>CampaignExtensionSettingReturnValue</ListReturnValue.Type><value><campaignId>346505693</campaignId><extensionType>SITELINK</extensionType><extensionSetting><extensions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="SitelinkFeedItem"><feedId>26419921</feedId><feedItemId>3856853919</feedItemId><status>ENABLED</status><feedType>SITELINK</feedType><ExtensionFeedItem.Type>SitelinkFeedItem</ExtensionFeedItem.Type><sitelinkText>Store Hours</sitelinkText><sitelinkFinalUrls><urls>http://www.example.com/storehours</urls></sitelinkFinalUrls></extensions><platformRestrictions>NONE</platformRestrictions></extensionSetting></value></rval></mutateResponse></soap:Body>

Result: Based on the response, you can see that the feed item ID that you get back is the same one you put in. Plus, you get back all the other details such as the site link text. I checked in the AdWords UI to make sure it was really the same site link by changing the site link text of Store Hours to Store Hours 1 in one campaign and then checking in the other campaign to see if the change was reflected. It looks like in the end I only ended up with one site link.

Please take a look at this and compare it to what you have. Perhaps, there's one field that you need to tweak in your code in order to get it to work. If you're still experiencing issues, I would be happy to take a more in-depth look.

Cheers,
Nadine, AdWords API Team

Danny

unread,
Feb 7, 2017, 4:14:04 PM2/7/17
to AdWords API Forum
Hi Nadine

Could you please share a sample code of adding an existing sitelink to an existing campaign via CampaignExtensionSettingServices? I'm trying to do something similar, but rather than create a new CampaignExtensionSetting, the CampaignExtensionSetting already exists with existing sitelinks (I'm just trying to add another SitelinkFeedItem to the extension setting).

When adding to the extension setting, do you simply create a new SitelinkFeedItem object and assign the 'FeedItemId' field with the existing ID (without populating anything else - e.g. status, feed type, start/end time) and when making the mutate request, the API will know to add the correct sitelink base on the 'FeedItemId' only?

Nadine Sundquist (AdWords API Team)

unread,
Feb 7, 2017, 4:34:41 PM2/7/17
to AdWords API Forum
Hi Danny,

Could you do me a huge favor and start a new thread with your question since your question is a bit different and this thread already has a solution? Feel free to refer to this thread in your forum post, and someone on my team will get back to you.

Thanks!
Nadine, AdWords API Team 
Reply all
Reply to author
Forward
0 new messages