Create and Update Sitelinks for Campaigns

130 views
Skip to first unread message

abc def

unread,
Jan 29, 2015, 5:52:56 AM1/29/15
to adwor...@googlegroups.com
Hi,

I am using the adwords api v201406 (I know there is a newer version) to generate campaigns, adgroups and so on.
For these campaigns I will add sitelinks. To ADD the sitelinks it works fine.
But sometimes I would like delete sitelinks and add new sitelinks in these campaigns. And this is my problem.

For my coding I use the examples from the PHP Library /AdvancedOperations/UpdateSitelinks.php and AddSitelinks.php.
So first I create a SitelinksFeed and then SitelinksFeedItems (my sitelinks for the campaigns) in the feed.
Then I create a SitelinksFeedMapping and put it with the SitelinksCampaignFeed into my campaign. This works.

But what I have to do to delete and add sitelinks in the same SitelinksCampaignFeed?
By generating the feed I store the feeds id getting from the api, and when putting a new sitelink in the feed, I use these id.
But I always get the errors

CampaignFeedError.FEED_ALREADY_EXISTS_FOR_PLACEHOLDER_TYPE @ operations[0].operand.placeholderTypes;
CampaignFeedError.CANNOT_ADD_ALREADY_EXISTING_CAMPAIGN_FEED @ operations[0].operand;

I think I had to use the feed, but there is the message that the feed exists.
And how to delete the campaign feed and add a new?

Is there any tutorial which helps me to add sitelinks in an existing SitelinksCampaignFeed?
Thank you. I hope you will understand my Problem.


Greetings from Germany,
Christian

Josh Radcliff (AdWords API Team)

unread,
Jan 29, 2015, 3:26:48 PM1/29/15
to adwor...@googlegroups.com
Hi Christian,

To modify which feed items are used for sitelinks for a given campaign, you would submit a CampaignFeedService.mutate request with a CampaignFeedOperation with:
  • operator = SET
  • operand = a CampaignFeed with:
    • feedId set to your feed ID
    • campaignId set to your campaign ID
    • placeholderTypes set to an array containing 1
    • matchingFunction modified with the new set of ConstantOperands pointing to the new set of feed item IDs
I'm guessing from the error you're receiving that you are trying to perform an ADD operation, but that's failing because you can only have one CampaignFeed for a given combination of feedId, campaignId, and placeholderType.

Cheers,
Josh, AdWords API Team

abc def

unread,
Feb 11, 2015, 12:10:54 PM2/11/15
to adwor...@googlegroups.com
Thanks for your reply!

I tried your hints, but now there is a new error:
RequestError.INVALID_INPUT @ ; trigger:'You are accessing an AdWords API version v201402 that has been discontinued. Calls to this version may fail. Please visit the AdWords API blog for information on migration to the new AdWords API version.'

But I am sure, that I use v201406. This is defined in the init.php:
define('ADWORDS_VERSION', 'v201406');

Where is my Problem?

Is there a tutorial which shows how to add and modify sitelinks via the API?

Josh Radcliff (AdWords API Team)

unread,
Feb 11, 2015, 2:01:47 PM2/11/15
to adwor...@googlegroups.com
Hi,

Regarding the version error, please make sure you are passing the proper version when retrieving the service, e.g.,

$feedService = $user->GetService('FeedService', ADWORDS_VERSION);

For more details on working with sitelinks, please read the Sitelinks guide. At the end of that guide are links to examples in each client library.

Thanks,
Josh, AdWords API Team
Message has been deleted

abc def

unread,
Feb 18, 2015, 10:50:12 AM2/18/15
to adwor...@googlegroups.com
Hi, thanks for your reply!

With your help now I can add and remove Sitelinks. But I have a further problem with the matchingFunction in a CampaignFeed. Every time I do an operation withe sitelinks, I get the following error:

Unmarshalling Error: cvc-enumeration-valid: Value 'ADD' is not facet-valid with respect to enumeration '[IN, IDENTITY, EQUALS, AND, UNKNOWN]'. It must be a value from the enumeration.

abc def

unread,
Feb 18, 2015, 10:50:22 AM2/18/15
to adwor...@googlegroups.com
Here is my code:

$combinedFunction = new \FeedFunction();
$combinedFunction->operator = 'IN';

$combinedFunction->lhsOperand = array($feedItemFunctionOperand, $platformFunctionOperand);

$campaignFeed = new \CampaignFeed();
$campaignFeed->feedId = $sitelinksData['sitelinksFeedId'];

$campaignFeed
->campaignId = $campaignId;
$campaignFeed
->matchingFunction = $combinedFunction;
$campaignFeed
->placeholderTypes = array(PLACEHOLDER_SITELINKS);

$operation
= new \CampaignFeedOperation();

$operation->operand = $campaignFeed;
$operation
->operand = 'ADD';

Where is the problem? First time generating a feed with sitelinks, I use the operand ADD, every next time when I would like to modify sitelinks, I use SET.
But the error above is there every time.

Josh Radcliff (AdWords API Team)

unread,
Feb 18, 2015, 12:18:40 PM2/18/15
to adwor...@googlegroups.com
Hi,

The operand should point to your CampaignFeed object, but the operator should be set to ADD. In your code, you are setting the operand twice.

$operation->operand = $campaignFeed;
$operation->operand = 'ADD';


Thanks,
Josh, AdWords API Team

abc def

unread,
Feb 20, 2015, 3:33:49 AM2/20/15
to adwor...@googlegroups.com
Oh no, it's a spelling error. My code is:

[...]
$operation->operand = $campaignFeed;
$operation->operator= 'ADD';
[...]


Josh Radcliff (AdWords API Team)

unread,
Feb 20, 2015, 10:14:36 AM2/20/15
to adwor...@googlegroups.com
Hi,

In that case, the issue is probably with either the $feedItemFunctionOperand or the $platformFunctionOperand you are using. Could you show the code you're using to create those objects?

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