Use the FeedItemSetService
to create a
FeedItemSet
, which is equivalent to a
location group in the Google
Ads UI.
There are two types of a feed item set: manual and dynamic.
Manual feed item set
Creating a manual feed item set requires you to specify two attributes:
- The resource name of the associated
Feed
of a location extension. Trying to associate the feed item set with other types of feed will result in theINVALID_FEED_TYPE
error. - The display name as a string
PHP
// Creates a new feed item set. $feedItemSet = new FeedItemSet([ 'feed' => ResourceNames::forFeed($customerId, $feedId), 'display_name' => 'Feed Item Set #' . uniqid() ]);
The created feed item set is empty, and you have to populate it by manually adding a feed item to it.
Adding a feed item to a feed item set
You can add a feed item to the manually created feed item set using
FeedItemSetLinkService
to create a
FeedItemSetLink
, which represents a link
between the feed item set and the feed item:
PHP
// Creates a new feed item set link that binds the specified feed item set and feed item. $feedItemSetLink = new FeedItemSetLink([ 'feed_item_set' => ResourceNames::forFeedItemSet($customerId, $feedId, $feedItemSetId), 'feed_item' => ResourceNames::forFeedItem($customerId, $feedId, $feedItemId) ]); // Constructs a feed item set link operation. $feedItemSetLinkOperation = new FeedItemSetLinkOperation(); $feedItemSetLinkOperation->setCreate($feedItemSetLink); // Issues a mutate request to add the feed item set link on the server. $feedItemSetLinkServiceClient = $googleAdsClient->getFeedItemSetLinkServiceClient(); $response = $feedItemSetLinkServiceClient->mutateFeedItemSetLinks( $customerId, [$feedItemSetLinkOperation] ); // Prints some information about the created feed item set link. printf( "Created a feed item set link with resource name '%s'.%s", $response->getResults()[0]->getResourceName(), PHP_EOL );
Dynamic feed item set
Creating a dynamic feed item set requires you to specify the two attributes that the manual feed item set requires, plus another attrbute which is different depending on the type of the associated feed:
Google Ads location extension
If the associated feed is a Google Ads location extension, you set
dynamic_location_set_filter
.
This lets you specify a business name as a filter. The feed item set will
then add the feed items of
Business Profile
that matches the name automatically.
PHP
$feedItemSet->setDynamicLocationSetFilter(new DynamicLocationSetFilter([ // Adds a filter for a business name using exact matching. 'business_name_filter' => new BusinessNameFilter([ 'business_name' => 'INSERT_YOUR_BUSINESS_NAME_HERE', 'filter_type' => FeedItemSetStringFilterType::EXACT ]) ]));
Affiliate location extension
If the associated feed is an affiliate extension, set
dynamic_affiliate_location_set_filter
.
This lets you specify a list of chain IDs. The feed item set will then add
the feed items of the specified chain IDs automatically. Visit
this page for the
list of available chain IDs.
PHP
$feedItemSet->setDynamicAffiliateLocationSetFilter( new DynamicAffiliateLocationSetFilter(['chain_ids' => [INSERT_CHAIN_IDS_HERE]]) );