Google Ads location extensions

To create Google Ads location extensions, you need to create a Google My Business (GMB) account and populate it with the addresses of all your business locations. Then, associate the GMB account with your location extensions feed to create the location extensions.

Google My Business

Google My Business (GMB) is the central repository for your business locations across all Google products. You don't have to worry about keeping your Google My Business locations and Google Ads location extensions in sync. Simply perform a one-time setup of the required feed objects for you. Google Ads will automatically keep its location extensions synchronized to the latest data from your Google My Business account.

There are two ways to create locations in Google My Business.

  1. You can use the Google My Business Location Manager for creating your locations. If you follow this approach, you can jump right to linking the locations to your ads using the Google Ads API.
  2. You can use the Google My Business API to create business locations programmatically.

Working with the Google My Business API

To get started with the Google My Business API, visit its home page. We recommend using business accounts rather than personal ones for locations linked to Google Ads. By using a business account, you can share access with other users without having to share your personal account details.

To create business locations programmatically using the Google My Business API,

  1. Start by downloading a client library. Follow the Basic setup guide to create OAuth credentials to work with the Google My Business API.

  2. Use the GMB API to list all the accounts that you own or have management rights on. Select the account to work with.

  3. Use the GMB API to create the locations.

Create a new location extensions feed linked to your GMB account

To create a new location extensions feed, start by creating a Feed object. Perform a FeedService.MutateFeeds create operation to create the feed. The code snippet is shown below.

Java

// Creates a feed that will sync to the Google My Business account. Do not add FeedAttributes to
// this object as Google Ads will add them automatically because this will be a system generated
// feed.
Feed.Builder gmbFeed =
    Feed.newBuilder()
        .setName(StringValue.of("Google My Business feed #" + System.currentTimeMillis()))
        // Configures the location feed populated from Google My Business Locations.
        .setPlacesLocationFeedData(placesLocationFeedData)
        // Since this feed's feed items will be managed by Google,
        // you must set its origin to GOOGLE.
        .setOrigin(FeedOrigin.GOOGLE);

FeedOperation operation = FeedOperation.newBuilder().setCreate(gmbFeed).build();

C#

private static string CreateGMBFeed(GoogleAdsClient client, long customerId,
    string gmbEmailAddress, string businessAccountId, string gmbAccessToken)
{
    // Optional: Delete all existing location extension feeds. This is an optional step,
    // and is required for this code example to run correctly more than once.
    // 1. Google Ads only allows one location extension feed per email address.
    // 2. A Google Ads account cannot have a location extension feed and an affiliate
    // location extension feed at the same time.
    DeleteLocationExtensionFeeds(client, customerId);

    // Get the FeedServiceClient.
    FeedServiceClient feedService = client.GetService(Services.V5.FeedService);

    // Creates a feed that will sync to the Google My Business account specified by
    // gmbEmailAddress. Do not add FeedAttributes to this object as Google Ads will add
    // them automatically because this will be a system generated feed.
    Feed gmbFeed = new Feed()
    {
        Name = "Google My Business feed #" + ExampleUtilities.GetRandomString(),

        PlacesLocationFeedData = new PlacesLocationFeedData()
        {
            EmailAddress = gmbEmailAddress,
            // If the EmailAddress is for a GMB manager instead of the GMB
            // account owner, then set BusinessAccountId to the Google+ Page ID of
            // a location for which the manager has access. This information is available
            // through the Google My Business API. See
            // https://developers.google.com/my-business/reference/rest/v4/accounts.locations#locationkey
            // for details.
            BusinessAccountId = string.IsNullOrEmpty(businessAccountId) ?
                null : businessAccountId,
            // Used to filter Google My Business listings by labels. If entries exist in
            // label_filters, only listings that have at least one of the labels set are
            // candidates to be synchronized into FeedItems. If no entries exist in
            // label_filters, then all listings are candidates for syncing.
            LabelFilters = { "Stores in New York" },
            // Sets the authentication info to be able to connect Google Ads to the GMB
            // account.
            OauthInfo = new OAuthInfo()
            {
                HttpMethod = "GET",
                HttpRequestUrl = GOOGLE_ADS_SCOPE,
                HttpAuthorizationHeader = $"Bearer {gmbAccessToken}"
            },
        },
        // Since this feed's feed items will be managed by Google,
        // you must set its origin to GOOGLE.
        Origin = FeedOrigin.Google
    };

    FeedOperation operation = new FeedOperation()
    {
        Create = gmbFeed
    };

    // Adds the feed.
    MutateFeedsResponse response =
        feedService.MutateFeeds(customerId.ToString(), new[] { operation });

    // Displays the results.
    string gmbFeedResourceName = response.Results[0].ResourceName;
    Console.WriteLine($"GMB feed created with resource name: {gmbFeedResourceName}.");
    return gmbFeedResourceName;
}

PHP

private static function createFeed(
    GoogleAdsClient $googleAdsClient,
    int $customerId,
    string $gmbEmailAddress,
    string $gmbAccessToken,
    string $businessAccountIdentifier
) {

    $gmbFeed = new Feed([
        'name' => new StringValue(['value' => 'Google My Business feed #' . uniqid()]),
        'origin' => FeedOrigin::GOOGLE,
        'places_location_feed_data' => new PlacesLocationFeedData([
            'email_address' => new StringValue(['value' => $gmbEmailAddress]),
            'business_account_id' => new StringValue(['value' => $businessAccountIdentifier]),
            // Used to filter Google My Business listings by labels. If entries exist in
            // label_filters, only listings that have at least one of the labels set are
            // candidates to be synchronized into FeedItems. If no entries exist in
            // label_filters, then all listings are candidates for syncing.
            'label_filters' => [new StringValue(['value' => 'Stores in New York'])],
            // Sets the authentication info to be able to connect Google Ads to the GMB
            // account.
            'oauth_info' => new OAuthInfo([
                'http_method' => new StringValue(['value' => 'GET']),
                'http_request_url' => new StringValue(['value' => self::GOOGLE_ADS_SCOPE]),
                'http_authorization_header' =>
                    new StringValue(['value' => 'Bearer ' . $gmbAccessToken])
            ])

        ])
    ]);
    // Creates a feed operation.
    $feedOperation = new FeedOperation();
    $feedOperation->setCreate($gmbFeed);

    // Issues a mutate request to add the feed and print its information.
    // Since it is a system generated feed, Google Ads will automatically:
    // 1. Set up the feed attributes on the feed.
    // 2. Set up a feed mapping that associates the feed attributes of the feed with the
    //    placeholder fields of the LOCATION placeholder type.
    $feedServiceClient = $googleAdsClient->getFeedServiceClient();
    $response = $feedServiceClient->mutateFeeds(
        $customerId,
        [$feedOperation]
    );
    $gmbFeedResourceName = $response->getResults()[0]->getResourceName();
    printf("GMB feed created with resource name: '%s'.%s", $gmbFeedResourceName, PHP_EOL);

    return $gmbFeedResourceName;
}

Ruby

def create_feed(
  client,
  customer_id,
  gmb_email_address,
  gmb_access_token,
  business_account_identifier)
  # Creates a feed operation.
  operation = client.operation.create_resource.feed do |feed|
    feed.name = "Google My Business feed #{(Time.new.to_f * 1000).to_i}"
    feed.origin = :GOOGLE
    feed.places_location_feed_data = client.resource.places_location_feed_data do |data|
      data.email_address = gmb_email_address
      data.business_account_id = business_account_identifier
      data.label_filters << "Stores in New York"
      data.oauth_info = client.resource.o_auth_info do |oauth|
        oauth.http_method = "GET"
        oauth.http_request_url = "https://www.googleapis.com/auth/adwords"
        oauth.http_authorization_header = "Bearer #{gmb_access_token}"
      end
    end
  end

  # Issues a mutate request to add the feed and print its information.
  # Since it is a system generated feed, Google Ads will automatically:
  # 1. Set up the feed attributes on the feed.
  # 2. Set up a feed mapping that associates the feed attributes of the feed with the
  #    placeholder fields of the LOCATION placeholder type.
  response = client.service.feed.mutate_feeds(
    customer_id: customer_id,
    operations: [operation],
  )

  # Prints out the GMB feed resource name.
  gmb_feed_resource_name = response.results.first.resource_name
  puts "GMB feed created with resource name: #{gmb_feed_resource_name}"

  gmb_feed_resource_name
end

Perl

# Create a feed that will sync to the Google My Business account specified by
# $gmb_email_address. Do not add FeedAttributes to this object as Google Ads
# will add them automatically because this will be a system generated feed.
my $gmb_feed = Google::Ads::GoogleAds::V5::Resources::Feed->new({
    name => "Google My Business feed #" . uniqid(),
    # Configure the location feed populated from Google My Business Locations.
    placesLocationFeedData =>
      Google::Ads::GoogleAds::V5::Resources::PlacesLocationFeedData->new({
        emailAddress      => $gmb_email_address,
        businessAccountId => $business_account_id,
        # Used to filter Google My Business listings by labels. If entries exist in
        # label_filters, only listings that have at least one of the labels set are
        # candidates to be synchronized into FeedItems. If no entries exist in
        # label_filters, then all listings are candidates for syncing.
        labelFilters => ["Stores in New York"],
        # Set the authentication info to be able to connect Google Ads to the GMB
        # account.
        oauthInfo => Google::Ads::GoogleAds::V5::Resources::OAuthInfo->new({
            httpMethod => "GET",
            httpRequestUrl =>
              Google::Ads::GoogleAds::Constants::DEFAULT_OAUTH2_SCOPE,
            httpAuthorizationHeader => "Bearer " . $gmb_access_token
          })}
      ),
    # Since this feed's feed items will be managed by Google, you must set its
    # origin to GOOGLE.
    origin => GOOGLE
  });


You need to populate the following fields that are specific to location extensions feeds:

Attribute Required Description
origin Yes Since the location extensions feed is system-generated, you need to set the origin field to GOOGLE.
attributes No Do not specify any attributes for the feed. Google Ads will create these for you automatically because this is a system-generated feed.
places_location_feed_data Yes Setting the places_location_feed_data attribute to a PlacesLocationFeedData object on your feed tells Google Ads to:
  • Link your Google My Business and Google Ads accounts.
  • Automatically create feed attributes for your feed.
  • Automatically create a FeedMapping LOCATION_EXTENSION_TARGETING criterion type.
  • (Optional) Limit the set of locations that Google Ads syncs from your Google My Business account.

Attributes of PlacesLocationFeedData

Attribute Required Description
email_address Yes The email address of your Google My Business account owner or one of its managers. This must match the email address provided in oauth_info.
oauth_info Yes OAuth2 information that grants your Google Ads account access to your Google My Business account. If you aren't familiar with OAuth2, read the authentication guide first.
business_account_id No The account ID of the managed business whose locations are to be used. If you are using the Google My Business API, you can get this ID from the account_id portion of the name of the Account. Otherwise, you can copy the LOCATION_GROUP_ID portion from the Location group info section of the specified location group.
business_name_filter No Name of the business to sync to Google Ads.
category_filters No Categories of the listings to sync to Google Ads.
label_filters No Labels of the listings to sync to Google Ads.

oauth_info attribute of PlacesLocationFeedData

Attribute Value Description
http_method GET The HTTP method for getting authorization information.
http_request_url https://www.googleapis.com/auth/adwords The OAuth scope that the Google Ads API uses to authorize your requests to Google My Business.
http_authorization_header Bearer OAUTH_ACCESS_TOKEN The authorization header containing the OAuth access token that grants your Google Ads account permission to read from your Google My Business account. In place of OAUTH_ACCESS_TOKEN, substitute an access token generated from OAuth credentials for the http_request_url of the PlacesLocationFeedData and a scope matching http_request_url.

Wait for the feed to be ready

Once the Feed is created, Google Ads will create the feed attributes and FeedMapping. Afterwards, it will populate the feed contents by creating the FeedItem objects that correspond to the locations in the GMB account.

You need to wait until the FeedMapping is created to ensure that the feed is properly set up, and that it can be used for the next steps. This can be done by attempting to retrieve the FeedMapping for the relevant feed with placeholder_type equal to LOCATION.

Java

try (FeedServiceClient feedServiceClient =
    googleAdsClient.getLatestVersion().createFeedServiceClient()) {
  // Adds the feed. Since it is a system generated feed, Google Ads will automatically:
  // 1. Set up the FeedAttributes on the feed.
  // 2. Set up a FeedMapping that associates the FeedAttributes of the feed
  // with the placeholder fields of the LOCATION placeholder type.
  MutateFeedsResponse response =
      feedServiceClient.mutateFeeds(Long.toString(customerId), ImmutableList.of(operation));
  String gmbFeedResourceName = response.getResults(0).getResourceName();
  System.out.printf("GMB feed created with resource name: %s%n", gmbFeedResourceName);

C#

private static FeedMapping GetGMBFeedMapping(GoogleAdsClient client, long customerId,
    string gmbFeedResourceName)
{
    // Get the GoogleAdsService.
    GoogleAdsServiceClient googleAdsService = client.GetService(
        Services.V5.GoogleAdsService);

    // Create the query.
    string query = $"SELECT feed_mapping.resource_name, feed_mapping.status FROM " +
        $"feed_mapping WHERE feed_mapping.feed = '{gmbFeedResourceName}' and " +
        $"feed_mapping.status = ENABLED and feed_mapping.placeholder_type = LOCATION" +
        $" LIMIT 1";

    // Issue a search request.
    PagedEnumerable<SearchGoogleAdsResponse, GoogleAdsRow> result =
        googleAdsService.Search(customerId.ToString(), query);

    // Display the results.
    GoogleAdsRow googleAdsRow = result.FirstOrDefault();
    return (googleAdsRow == null) ? null : googleAdsRow.FeedMapping;
}

PHP

// Issues a mutate request to add the feed and print its information.
// Since it is a system generated feed, Google Ads will automatically:
// 1. Set up the feed attributes on the feed.
// 2. Set up a feed mapping that associates the feed attributes of the feed with the
//    placeholder fields of the LOCATION placeholder type.
$feedServiceClient = $googleAdsClient->getFeedServiceClient();
$response = $feedServiceClient->mutateFeeds(
    $customerId,
    [$feedOperation]
);
$gmbFeedResourceName = $response->getResults()[0]->getResourceName();
printf("GMB feed created with resource name: '%s'.%s", $gmbFeedResourceName, PHP_EOL);

return $gmbFeedResourceName;

Ruby

# Issues a mutate request to add the feed and print its information.
# Since it is a system generated feed, Google Ads will automatically:
# 1. Set up the feed attributes on the feed.
# 2. Set up a feed mapping that associates the feed attributes of the feed with the
#    placeholder fields of the LOCATION placeholder type.
response = client.service.feed.mutate_feeds(
  customer_id: customer_id,
  operations: [operation],
)

# Prints out the GMB feed resource name.
gmb_feed_resource_name = response.results.first.resource_name
puts "GMB feed created with resource name: #{gmb_feed_resource_name}"

gmb_feed_resource_name

Perl

# Add the feed. Since it is a system generated feed, Google Ads will automatically:
# 1. Set up the FeedAttributes on the feed.
# 2. Set up a FeedMapping that associates the FeedAttributes of the feed with the
#    placeholder fields of the LOCATION placeholder type.
my $feed_response = $api_client->FeedService()->mutate({
    customerId => $customer_id,
    operations => [$feed_operation]});

my $feed_resource_name = $feed_response->{results}[0]{resourceName};

printf "GMB feed created with resource name: '%s'.\n", $feed_resource_name;

If the FeedMapping is not yet available, retry the calls with an exponential back-off policy until the Feed is ready.

Java

try (CustomerFeedServiceClient customerFeedServiceClient =
    googleAdsClient.getLatestVersion().createCustomerFeedServiceClient()) {

  // After the completion of the Feed ADD operation above the added feed will not be available
  // for usage in a CustomerFeed until the sync between the Google Ads and GMB accounts
  // completes. The loop below will retry adding the CustomerFeed up to ten times with an
  // exponential back-off policy.
  String addedCustomerFeed = null;
  int numberOfAttempts = 0;
  do {
    numberOfAttempts++;
    try {
      MutateCustomerFeedsResponse customerFeedsResponse =
          customerFeedServiceClient.mutateCustomerFeeds(
              Long.toString(customerId), ImmutableList.of(customerFeedOperation));
      addedCustomerFeed = customerFeedsResponse.getResults(0).getResourceName();
      System.out.printf("Customer feed created with resource name: %s%n", addedCustomerFeed);
    } catch (GoogleAdsException gae) {
      // Waits using exponential backoff policy.
      long sleepSeconds = (long) Math.scalb(5, numberOfAttempts);

      // Exits the loop early if sleepSeconds grows too large in the event that
      // MAX_CUSTOMER_FEED_ADD_ATTEMPTS is set too high.
      if (sleepSeconds > (long) Math.scalb(5, 10)) {
        break;
      }

      System.out.printf(
          "Attempt #%d to add the CustomerFeed was not successful. "
              + "Waiting %d seconds before trying again.%n",
          numberOfAttempts, sleepSeconds);
      Thread.sleep(sleepSeconds * 1000);
    }
  }

C#

private static void WaitForGMBFeedToBeReady(GoogleAdsClient client, long customerId,
    string gmbFeedResourceName)
{
    int numAttempts = 0;
    int sleepSeconds = 0;

    while (numAttempts < MAX_FEEDMAPPING_RETRIEVAL_ATTEMPTS)
    {
        // Once you create a feed, Google's servers will setup the feed by creating feed
        // attributes and feedmapping. Once the feedmapping is created, it is ready to be
        // used for creating customer feed.
        // This process is asynchronous, so we wait until the feed mapping is created,
        // peforming exponential backoff.
        FeedMapping feedMapping = GetGMBFeedMapping(client,
            customerId, gmbFeedResourceName);

        if (feedMapping == null)
        {
            numAttempts++;
            sleepSeconds = (int) (5 * Math.Pow(2, numAttempts));
            Console.WriteLine($"Checked: #{numAttempts} time(s). GMB feed is not ready " +
                $"yet. Waiting {sleepSeconds} seconds before trying again.");
            Thread.Sleep(sleepSeconds * 1000);
        }
        else
        {
            Console.WriteLine($"GMB Feed {gmbFeedResourceName} is now ready.");
            return;
        }
    }
    throw new RpcException(new Status(StatusCode.DeadlineExceeded,
        $"GMB Feed is not ready after {MAX_FEEDMAPPING_RETRIEVAL_ATTEMPTS}" +
        $" retries."));
}

PHP

// After the completion of the feed ADD operation above the added feed will not be available
// for usage in a customer feed until the sync between the Google Ads and GMB accounts
// completes. The loop below will retry adding the customer feed up to ten times with an
// exponential back-off policy.
$numberOfAttempts = 0;
$addedCustomerFeed = null;
$customerFeedServiceClient = $googleAdsClient->getCustomerFeedServiceClient();
do {
    $numberOfAttempts++;
    try {
        // Issues a mutate request to add a customer feed and print its information if the
        // request succeeded.
        $addedCustomerFeed = $customerFeedServiceClient->mutateCustomerFeeds(
            $customerId,
            [$customerFeedOperation]
        );
        printf(
            "Customer feed created with resource name: '%s'.%s",
            $addedCustomerFeed->getResults()[0]->getResourceName(),
            PHP_EOL
        );
    } catch (GoogleAdsException $googleAdsException) {
        // Waits using exponential backoff policy.
        $sleepSeconds = self::POLL_FREQUENCY_SECONDS * pow(2, $numberOfAttempts);
        // Exits the loop early if $sleepSeconds grows too large in the event that
        // MAX_CUSTOMER_FEED_ADD_ATTEMPTS is set too high.
        if (
            $sleepSeconds > self::POLL_FREQUENCY_SECONDS
            * pow(2, self::MAX_CUSTOMER_FEED_ADD_ATTEMPTS)
        ) {
            break;
        }
        printf(
            "Attempt #%d to add the customer feed was not successful."
            . " Waiting %d seconds before trying again.%s",
            $numberOfAttempts,
            $sleepSeconds,
            PHP_EOL
        );
        sleep($sleepSeconds);
    }
}

Ruby

# After the completion of the feed ADD operation above the added feed will
# not be available for usage in a customer feed until the sync between the
# Google Ads and GMB accounts completes. The loop below will retry adding the
# customer feed up to ten times with an exponential back-off policy.
number_of_attempts = 0
added_customer_feed = nil
customer_feed_service_client = client.service.customer_feed

loop do
  number_of_attempts += 1
  begin
    # Issues a mutate request to add a customer feed and print its information
    # if the request succeeded.
    response = customer_feed_service_client.mutate_customer_feeds(
      customer_id: customer_id,
      operations: [operation]
    )
    puts "Customer feed created with resource name: " \
      "#{response.results.first.resource_name}"
  rescue Google::Ads::GoogleAds::Errors::GoogleAdsError => e
    # Waits using exponential backoff policy
    sleep_seconds = POLL_FREQUENCY_SECONDS * (2 ** number_of_attempts)
    puts "Attempt #{number_of_attempts} to add the customer feed was " \
      "not successful. Waiting #{sleep_seconds} seconds before trying again."
    sleep sleep_seconds
  end
  break if number_of_attempts >= MAX_CUSTOMER_FEED_ADD_ATTEMPTS || added_customer_feed
end

Perl

# After the completion of the Feed ADD operation above the added feed will not be available
# for usage in a CustomerFeed until the sync between the Google Ads and GMB accounts
# completes. The loop below will retry adding the CustomerFeed up to ten times with an
# exponential back-off policy.
my $customer_feed_service       = $api_client->CustomerFeedService();
my $customer_feed_resource_name = undef;
my $number_of_attempts          = 0;

while ($number_of_attempts < MAX_CUSTOMER_FEED_ADD_ATTEMPTS) {
  $number_of_attempts++;

  my $customer_feed_response = eval {
    $customer_feed_service->mutate({
      customerId => $customer_id,
      operations => [$customer_feed_operation],
    });
  };

  if ($@) {
    # Wait using exponential backoff policy.
    my $sleep_seconds = 5 * (2**$number_of_attempts);

    # Exit the loop early if $sleep_seconds grows too large in the event that
    # MAX_CUSTOMER_FEED_ADD_ATTEMPTS is set too high.
    if ($sleep_seconds > 5 * (2**10)) {
      last;
    }

    printf "Attempt #%d to add the CustomerFeed was not successful. " .
      "Waiting %d seconds before trying again.\n",
      $number_of_attempts, $sleep_seconds;

    sleep($sleep_seconds);
  } else {
    $customer_feed_resource_name =
      $customer_feed_response->{results}[0]{resourceName};

    printf "Customer feed created with resource name: '%s'.\n",
      $customer_feed_resource_name;

    last;
  }
}

Associate the feed with the customer

Once the feed is ready, you can associate it with a customer by creating a CustomerFeed. Then perform a CustomerFeedService.MutateCustomerFeeds create operation to complete the linking.

The following fields of the CustomerFeed should be set.

Attribute Value Description
feed The feed resource name. The resource name of the feed that was created in the previous step.
placeholder_types LOCATION Indicates that this feed populates location extensions under the connected customer.
matching_function IDENTITY(true) to mark this feed as enabled, and IDENTITY(false) to mark this feed as disabled. See filtering strategies for more details.

Java

// Adds a CustomerFeed that associates the feed with this customer for
// the LOCATION placeholder type.
CustomerFeed customerFeed =
    CustomerFeed.newBuilder()
        .setFeed(StringValue.of(gmbFeedResourceName))
        .addPlaceholderTypes(PlaceholderType.LOCATION)
        // Creates a matching function that will always evaluate to true.
        .setMatchingFunction(
            MatchingFunction.newBuilder()
                .addLeftOperands(
                    Operand.newBuilder()
                        .setConstantOperand(
                            ConstantOperand.newBuilder()
                                .setBooleanValue(BoolValue.of(true))
                                .build())
                        .build())
                .setFunctionString(StringValue.of("IDENTITY(true)"))
                .setOperator(MatchingFunctionOperator.IDENTITY)
                .build())
        .build();

CustomerFeedOperation customerFeedOperation =
    CustomerFeedOperation.newBuilder().setCreate(customerFeed).build();

C#

private static void CreateCustomerFeed(GoogleAdsClient client, long customerId,
    string gmbFeedResourceName)
{
    // Get the CustomerFeedService.
    CustomerFeedServiceClient customerFeedService = client.GetService(
        Services.V5.CustomerFeedService);

    // Adds a CustomerFeed that associates the feed with this customer for
    // the LOCATION placeholder type.
    CustomerFeed customerFeed = new CustomerFeed()
    {
        Feed = gmbFeedResourceName,
        PlaceholderTypes = { PlaceholderType.Location },
        MatchingFunction = new MatchingFunction()
        {
            LeftOperands =
            {
                new Operand()
                {
                    ConstantOperand = new ConstantOperand()
                    {
                        BooleanValue = true
                    }
                }
            },
            // Specify the function string as IDENTITY(true) to mark this feed as enabled.
            FunctionString = "IDENTITY(true)",
            Operator = MatchingFunctionOperator.Identity
        },
    };

    CustomerFeedOperation operation = new CustomerFeedOperation()
    {
        Create = customerFeed
    };

    MutateCustomerFeedsResponse customerFeedsResponse =
        customerFeedService.MutateCustomerFeeds(
            customerId.ToString(), new[] { operation });

    // Displays the result.
    string addedCustomerFeed = customerFeedsResponse.Results[0].ResourceName;
    Console.WriteLine($"Customer feed created with resource name: {addedCustomerFeed}.");
    return;
}

PHP

private static function createCustomerFeed(
    GoogleAdsClient $googleAdsClient,
    int $customerId,
    string $gmbFeedResourceName
) {
    // Creates a customer feed that associates the feed with this customer for the LOCATION
    // placeholder type.
    $customerFeed = new CustomerFeed([
        'feed' => new StringValue(['value' => $gmbFeedResourceName]),
        'placeholder_types' => [PlaceholderType::LOCATION],
        // Creates a matching function that will always evaluate to true.
        'matching_function' => new MatchingFunction([
            'left_operands' => [new Operand([
                'constant_operand' => new ConstantOperand([
                    'boolean_value' => new BoolValue(['value' => true])
                ])
            ])],
            'function_string' => new StringValue(['value' => 'IDENTITY(true)']),
            'operator' => MatchingFunctionOperator::IDENTITY
        ])
    ]);
    // Creates a customer feed operation.
    $customerFeedOperation = new CustomerFeedOperation();
    $customerFeedOperation->setCreate($customerFeed);

    // After the completion of the feed ADD operation above the added feed will not be available
    // for usage in a customer feed until the sync between the Google Ads and GMB accounts
    // completes. The loop below will retry adding the customer feed up to ten times with an
    // exponential back-off policy.
    $numberOfAttempts = 0;
    $addedCustomerFeed = null;
    $customerFeedServiceClient = $googleAdsClient->getCustomerFeedServiceClient();
    do {
        $numberOfAttempts++;
        try {
            // Issues a mutate request to add a customer feed and print its information if the
            // request succeeded.
            $addedCustomerFeed = $customerFeedServiceClient->mutateCustomerFeeds(
                $customerId,
                [$customerFeedOperation]
            );
            printf(
                "Customer feed created with resource name: '%s'.%s",
                $addedCustomerFeed->getResults()[0]->getResourceName(),
                PHP_EOL
            );
        } catch (GoogleAdsException $googleAdsException) {
            // Waits using exponential backoff policy.
            $sleepSeconds = self::POLL_FREQUENCY_SECONDS * pow(2, $numberOfAttempts);
            // Exits the loop early if $sleepSeconds grows too large in the event that
            // MAX_CUSTOMER_FEED_ADD_ATTEMPTS is set too high.
            if (
                $sleepSeconds > self::POLL_FREQUENCY_SECONDS
                * pow(2, self::MAX_CUSTOMER_FEED_ADD_ATTEMPTS)
            ) {
                break;
            }
            printf(
                "Attempt #%d to add the customer feed was not successful."
                . " Waiting %d seconds before trying again.%s",
                $numberOfAttempts,
                $sleepSeconds,
                PHP_EOL
            );
            sleep($sleepSeconds);
        }
    } while (
        $numberOfAttempts < self::MAX_CUSTOMER_FEED_ADD_ATTEMPTS
        && is_null($addedCustomerFeed)
    );

    if (is_null($addedCustomerFeed)) {
        throw new \RuntimeException(
            'Could not create the customer feed after ' . self::MAX_CUSTOMER_FEED_ADD_ATTEMPTS
            . ' attempts. Please retry the customer feed ADD operation later.'
        );
    }
}

Ruby

def create_customer_feed(
  client,
  customer_id,
  gmb_feed_resource_name)
  # Creates a customer feed operation.
  operation = client.operation.create_resource.customer_feed do |cf|
    cf.feed = gmb_feed_resource_name
    cf.placeholder_types << :LOCATION
    cf.matching_function = client.resource.matching_function do |m|
      m.left_operands << client.resource.operand do |op|
        op.constant_operand = client.resource.constant_operand do |co|
          co.boolean_value = true
        end
      end
      m.function_string = "IDENTITY(true)"
      m.operator = :IDENTITY
    end
  end

  # After the completion of the feed ADD operation above the added feed will
  # not be available for usage in a customer feed until the sync between the
  # Google Ads and GMB accounts completes. The loop below will retry adding the
  # customer feed up to ten times with an exponential back-off policy.
  number_of_attempts = 0
  added_customer_feed = nil
  customer_feed_service_client = client.service.customer_feed

  loop do
    number_of_attempts += 1
    begin
      # Issues a mutate request to add a customer feed and print its information
      # if the request succeeded.
      response = customer_feed_service_client.mutate_customer_feeds(
        customer_id: customer_id,
        operations: [operation]
      )
      puts "Customer feed created with resource name: " \
        "#{response.results.first.resource_name}"
    rescue Google::Ads::GoogleAds::Errors::GoogleAdsError => e
      # Waits using exponential backoff policy
      sleep_seconds = POLL_FREQUENCY_SECONDS * (2 ** number_of_attempts)
      puts "Attempt #{number_of_attempts} to add the customer feed was " \
        "not successful. Waiting #{sleep_seconds} seconds before trying again."
      sleep sleep_seconds
    end
    break if number_of_attempts >= MAX_CUSTOMER_FEED_ADD_ATTEMPTS || added_customer_feed
  end

  if added_customer_feed.nil?
    raise "Could not create the customer feed after #{MAX_CUSTOMER_FEED_ADD_ATTEMPTS} " \
      "attempts. Please retry the customer feed ADD operation later."
  end
end

Perl

# Add a CustomerFeed that associates the feed with this customer for the LOCATION
# placeholder type.
my $customer_feed = Google::Ads::GoogleAds::V5::Resources::CustomerFeed->new({
    feed             => $feed_resource_name,
    placeholderTypes => LOCATION,
    # Create a matching function that will always evaluate to true.
    matchingFunction =>
      Google::Ads::GoogleAds::V5::Common::MatchingFunction->new({
        leftOperands => [
          Google::Ads::GoogleAds::V5::Common::Operand->new({
              constantOperand =>
                Google::Ads::GoogleAds::V5::Common::ConstantOperand->new({
                  booleanValue => "true"
                })})
        ],
        functionString => "IDENTITY(true)",
        operator       => IDENTITY
      })});