← 返回目录
来源:Google Ads API 官方文档 · 中文版 · 本地归档

地理位置定位

本指南对地理位置定位进行了说明,并介绍了如何使用 Google Ads API 为您的广告系列添加、获取及更新地理位置定位。

如需了解定位限制,请参阅 Google Ads 账号限制简介的“定位限制”部分。

为什么地理位置定位如此重要?

借助地理位置定位,您可以向特定地理区域的用户投放您的广告。例如,假设您要为某个连锁超市投放广告。 如果不使用地理位置定位,您的广告就会在全球所有区域展示,而其中一些区域并未开设该连锁超市,那里的用户可能也会点击您的广告。这除了浪费您的预算之外,还不会带来任何投资回报。但采用了地理位置定位后,您的广告系列就只会在开设了该连锁超市的区域展示广告。这种方法还可以让您直接定位在本地搜索超市的客户。

通过 Google Ads API,您可以根据国家/地区、区域或特定地理位置点的邻近区域来定位您的广告。

详细了解如何将广告定位到地理位置。

通过地理位置将广告系列定位到区域

您可以将广告系列定位到 Google Ads 支持进行地理位置定位的任何地理区域,例如国家/地区、州或省、城市或邮政区域。每个可定位的地理位置都会有一个条件 ID 进行唯一地标识。您可以查找条件 ID,方法是使用GeoTargetConstantService.SuggestGeoTargetConstants。每个 GeoTargetConstant 的 resource_name 的格式为 geoTargetConstants/{Criterion ID}。例如,纽约州的 resource_name 值为 geoTargetConstants/21167。

您可以使用 CampaignCriterionService为您的广告系列添加地理位置定位。以下代码段展示了如何使用条件 ID 对广告系列进行定位。

Java

private static CampaignCriterion buildLocationIdCriterion(
    long locationId, String campaignResourceName) {
  Builder criterionBuilder = CampaignCriterion.newBuilder().setCampaign(campaignResourceName);

  criterionBuilder
      .getLocationBuilder()
      .setGeoTargetConstant(ResourceNames.geoTargetConstant(locationId));

  return criterionBuilder.build();
}
      

C#

private CampaignCriterion buildLocationCriterion(long locationId,
    string campaignResourceName)
{
    GeoTargetConstantName location = new GeoTargetConstantName(locationId.ToString());
    return new CampaignCriterion()
    {
        Campaign = campaignResourceName,
        Location = new LocationInfo()
        {
            GeoTargetConstant = location.ToString()
        }
    };
}
      

PHP

private static function createLocationCampaignCriterionOperation(
    int $locationId,
    string $campaignResourceName
) {
    // Constructs a campaign criterion for the specified campaign ID using the specified
    // location ID.
    $campaignCriterion = new CampaignCriterion([
        // Creates a location using the specified location ID.
        'location' => new LocationInfo([
            // Besides using location ID, you can also search by location names using
            // GeoTargetConstantServiceClient::suggestGeoTargetConstants() and directly
            // apply GeoTargetConstant::$resourceName here. An example can be found
            // in GetGeoTargetConstantByNames.php.
            'geo_target_constant' => ResourceNames::forGeoTargetConstant($locationId)
        ]),
        'campaign' => $campaignResourceName
    ]);

    return new CampaignCriterionOperation(['create' => $campaignCriterion]);
}
在接这个接口时卡住了?
Stuck wiring this API into production? We build ad-delivery tooling on these platforms — campaign automation, reporting pipelines, error-handling and migration between API versions.
联系我们 · Talk to us 每日平台更新简报 →