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

示例:使用 Google Merchant Center 制作动态再营销广告系列

在此示例中,您有一个零售网站,该网站会将商品详情上传到 Google Merchant Center,并且您希望向访问过该零售网站的用户再营销一组商品。这些用户可能访问过产品页面,或将商品放入购物车或结账,而这些行为会触发再营销标记。然后,您可以制作一个广告系列,仅定位此群组,也可以定位类似受众群体,以扩大覆盖面。

详细了解受众群体名单生成最佳实践。

您需要具备以下条件才能设置此类广告系列:

  1. 再营销名单。
  2. Merchant Center 账号。
  3. 来自 Merchant Center 的商品 Feed。
  4. 自适应展示广告所需的媒体资源。

以下是支持 Merchant Center 商品 Feed 的广告素材列表:

第 1 步 - 制作与 Merchant Center 产品 Feed 相关联的广告系列

如需对零售商品进行再营销,您需要制作以展示广告网络为定位目标的广告系列。这需要满足以下条件:

  • 一个 CampaignBudget,用于指定广告系列能够支出的金额。
  • 一个 UserList,其中包含要通过相应广告系列定位的用户名单。
  • ShoppingSetting 用于指定商品 Feed 将用于哪个 Merchant Center 账号的广告系列。

配置广告系列的基本步骤如下:

  1. 制作新的广告系列,并将 AdvertisingChannelType 设置为 DISPLAY。

  2. 为广告系列设置CampaignBudget。可以是新创建的预算,也可以是共享预算。

  3. 为广告系列设置 ShoppingSetting。请注意,此处使用的是 CampaignService,而不是 AdGroupService,因为 Feed 必须附加到广告系列一级。

  4. 应用 mutate 操作,将新广告系列添加到账号中。

代码示例

Java

private String createCampaign(
    GoogleAdsClient googleAdsClient,
    long customerId,
    long merchantCenterAccountId,
    long campaignBudgetId) {
  String budgetResourceName = ResourceNames.campaignBudget(customerId, campaignBudgetId);

  // Creates the campaign.
  Campaign campaign =
      Campaign.newBuilder()
          .setName("Shopping campaign #" + getPrintableDateTime())
          // Dynamic remarketing campaigns are only available on the Google Display Network.
          .setAdvertisingChannelType(AdvertisingChannelType.DISPLAY)
          .setStatus(CampaignStatus.PAUSED)
          .setCampaignBudget(budgetResourceName)
          .setManualCpc(ManualCpc.newBuilder().build())
          // The settings for the shopping campaign.
          // This connects the campaign to the merchant center account.
          .setShoppingSetting(
              ShoppingSetting.newBuilder()
                  .setCampaignPriority(0)
                  .setMerchantId(merchantCenterAccountId)
                  .setEnableLocal(true)
                  .build())
          // Declares whether this campaign serves political ads targeting the EU.
          .setContainsEuPoliticalAdvertising(DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING)
          .build();

  // Creates the campaign operation.
  CampaignOperation operation = CampaignOperation.newBuilder().setCreate(campaign).build();

  // Creates the campaign service client.
  try (CampaignServiceClient campaignServiceClient =
      googleAdsClient.getLatestVersion().createCampaignServiceClient()) {
    // Adds the campaign.
    MutateCampaignsResponse response =
        campaignServiceClient.mutateCampaigns(
            Long.toString(customerId), ImmutableList.of(operation));
    String campaignResourceName = response.getResults(0).getResourceName();
    System.out.printf("Created campaign with resource name '%s'.%n", campaignResourceName);
    return campaignResourceName;
  }
}

      

C#

private string CreateCampaign(GoogleAdsClient client, long customerId,
    long merchantCenterAccountId, long campaignBudgetId)
{
    // Creates the Campaign Service client.
    CampaignServiceClient campaignServiceClient =
        client.GetService(Services.V25.CampaignService);

    string budgetResourceName = ResourceNames.CampaignBudget(customerId, campaignBudgetId);

    // Creates the campaign.
    Campaign campaign = new Campaign()
    {
        Name = "Shopping campaign #" + ExampleUtilities.GetRandomString(),
        // Dynamic remarketing campaigns are only available on the Google Display Network.
        AdvertisingChannelType = AdvertisingChannelType.Display,
        Status = CampaignStatus.Paused,
        CampaignBudget = budgetResourceName,
        ManualCpc = new ManualCpc(),
        // The settings for the shopping campaign.
        // This connects the campaign to the Merchant Center account.
        ShoppingSetting = new Campaign.Types.ShoppingSetting()
        {
            CampaignPriority = 0,
            MerchantId = merchantCenterAccountId,
            EnableLocal = true
        },

        // Declare whether or not this campaign contains political ads targeting the EU.
        ContainsEuPoliticalAdvertising = EuPoliticalAdvertisingStatus.DoesNotContainEuPoliticalAdvertising,
    };

    // Creates the campaign operation.
    CampaignOperation operation = new CampaignOperation()
    {
        Create = campaign
    };

    // Adds the campaign.
    MutateCampaignsResponse response = campaignServiceClient.MutateCampaigns(customerId
        .ToString(), new[] { operation });
    string campaignResourceName = response.Results.First().ResourceName;
    Console.WriteLine($"Created campaign with resource name '{campaignResourceName}'.");
    return campaignResourceName;
}
      

PHP

private static function createCampaign(
    GoogleAdsClient $googleAdsClient,
    int $customerId,
    int $merchantCenterAccountId,
    int $campaignBudgetId
): string {
    // Configures the settings for the shopping campaign.
    $shoppingSettings = new ShoppingSetting([
        'campaign_priority' => 0,
        'merchant_id' => $merchantCenterAccountId,
        'enable_local' => true
    ]);

    // Creates the campaign.
    $campaign = new Campaign([
        'name' => 'Shopping campaign #' . Helper::getPrintableDatetime(),
        // Dynamic remarketing campaigns are only available on the Google Display Network.
        'advertising_channel_type' => AdvertisingChannelType::DISPLAY,
        'status' => CampaignStatus::PAUSED,
        'campaign_budget' => ResourceNames::forCampaignBudget($customerId, $campaignBudgetId),
        'manual_cpc' => new ManualCpc(),
        // Declare whether or not this campaign serves political ads targeting the EU.
        'contains_eu_political_advertising' =>
            EuPoliticalAdvertisingStatus::DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING
        // This connects the campaign to the merchant center account.
        'shopping_setting' => $shoppingSettings
    ]);

    // Creates a campaign operation.
    $campaignOperation = new CampaignOperation();
    $campaignOperation->setCreate($campaign);

    // Issues a mutate request to add the campaign.
    $campaignServiceClient = $googleAdsClient->getCampaignServiceClient();
    $response = $campaignServiceClient->mutateCampaigns(
        MutateCampaignsRequest::build($customerId, [$campaignOperation])
    );

    /** @var Campaign $addedCampaign */
    $addedCampaign = $response->getResults()[0];
    $addedCampaignResourceName = $addedCampaign->getResourceName();
    printf("Created campaign with resource name '%s'.%s", $addedCampaignResourceName, PHP_EOL);

    return $addedCampaignResourceName;
}
在接这个接口时卡住了?
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 每日平台更新简报 →