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

执行了特定操作的访问者

您可以将在您的网站上采取了具体操作的用户填充到受众群体名单。如果您使用转化跟踪,则可以将广告定位到之前在您的网站上触发过转化的用户(例如完成过购买交易的用户)。

此外,您还可以将广告定位到在您的网站上采取了未归入转化的特定操作的用户,如某人将某商品添加到购物车,但随后又删除而没有购买。

前提条件

如需创建和定位目标受众群体细分,您首先需要:

  1. 查看针对用户兴趣和地理位置投放广告的政策。 有关用户的敏感信息不能用于创建受众群体。

  2. 设置 Google 代码。

    如果广告客户希望根据移动应用行为创建用户名单,则应实现 Firebase SDK 或使用第三方 SDK 来跟踪应用内行为。

1. 设置转化跟踪。按照转化管理入门指南中的说明进行操作。然后,在您的网站上添加 Google 代码。

检索 Google 代码

所有 Google Ads 账号都只有一个账号级 Google 代码,该代码会在账号开通时自动创建。

您可以在 Google Ads 界面中按照帮助中心说明检索 Google 代码,也可以在 Google Ads API 中通过创建 RemarketingAction 来检索 Google 代码,然后使用 remarketing_action 资源发出 GoogleAdsService.searchStream 请求:

SELECT
  remarketing_action.id,
  remarketing_action.name,
  remarketing_action.tag_snippets
FROM remarketing_action
WHERE remarketing_action.resource_name = 'REMARKETING_ACTION_RESOURCE_NAME'

在网站或应用中添加 Google 代码

接下来,您需要在网站的所有网页上添加 Google 代码。详细了解如何向网站或移动应用添加 Google 代码。

如果您计划仅根据访问过的网页网址来构建细分受众群,则无需对 Google 代码进行任何修改。如果您使用自定义参数,则需要修改代码以加入这些参数,如编写代码和创建再营销名单的高级策略中所述。

您可以使用 Google Tag Assistant 验证代码植入情况。

内置 Google 代码参数

您可以使用内置的再营销参数 url__,根据用户在您网站上访问过的网址来定位用户名单,如网站访问者示例中所示。

自定义 Google 代码参数

您可以向 Google 代码添加自定义 Google 代码参数,以创建更精细的用户名单。

在创建自己的自定义参数之前,请查看预定义参数列表,看看是否已有适合您用例的参数。使用预定义的参数可以更轻松地与其他 Google Ads 再营销功能集成。

创建用户列表

如需定位采取了特定行动的访问者,您需要使用包含对所定位行动(无论是转化行动还是非转化行动)的引用的 BasicUserListInfo 对象,为 UserList 的 basic_user_list 字段设置值。

如需查看一个完整示例场景,了解如何根据转化操作和非转化操作的组合来定位用户,请参阅示例场景。

触发了转化的访问者

基本用户名单的成员资格是指曾在您的网站上触发过一项或多项转化操作的用户。创建基本用户名单时,您需要向 UserListActionInfo 对象提供 ConversionAction 的资源名称,该对象最终会传递给 UserList。

以下示例创建了一个与两个现有转化操作相关联的基本用户名单:

Java

private void runExample(
    GoogleAdsClient googleAdsClient, long customerId, List<Long> conversionActionIds) {
  List<UserListActionInfo> userListActionInfoList = new ArrayList<>();
  for (long conversionActionId : conversionActionIds) {
    // Creates the UserListActionInfo object for a given conversion action. This specifies the
    // conversion action that, when triggered, will cause a user to be added to a UserList.
    UserListActionInfo userListActionInfo =
        UserListActionInfo.newBuilder()
            .setConversionAction(ResourceNames.conversionAction(customerId, conversionActionId))
            .build();
    userListActionInfoList.add(userListActionInfo);
  }

  // Creates a basic user list info object with all of the conversion actions.
  BasicUserListInfo basicUserListInfo =
      BasicUserListInfo.newBuilder().addAllActions(userListActionInfoList).build();

  // Creates the basic user list.
  UserList basicUserList =
      UserList.newBuilder()
          .setName("Example BasicUserList #" + getPrintableDateTime())
          .setDescription("A list of people who have triggered one or more conversion actions")
          .setMembershipLifeSpan(365)
          .setBasicUserList(basicUserListInfo)
          .setMembershipStatus(UserListMembershipStatus.OPEN)
          .build();

  // Creates the operation.
  UserListOperation operation = UserListOperation.newBuilder().setCreate(basicUserList).build();

  // Creates the service client.
  try (UserListServiceClient userListServiceClient =
      googleAdsClient.getLatestVersion().createUserListServiceClient()) {
    // Adds the basic user list.
    MutateUserListsResponse response =
        userListServiceClient.mutateUserLists(
            Long.toString(customerId), ImmutableList.of(operation));
    // Prints the results.
    System.out.printf(
        "Created basic user list with resource name '%s'.%n",
        response.getResults(0).getResourceName());
  }
}
      

C#

public void Run(GoogleAdsClient client, long customerId, long[] conversionActionIds)
{
    // Creates the service client.
    UserListServiceClient userListServiceClient =
        client.GetService(Services.V25.UserListService);

    List<UserListActionInfo> userListActionInfoList = new List<UserListActionInfo>();
    foreach (long conversionActionId in conversionActionIds)
    {
        // Creates the UserListActionInfo object for a given conversion action. This
        // specifies the conversion action that, when triggered, will cause a user to be
        // added to a UserList.
        userListActionInfoList.Add(new UserListActionInfo
        {
            ConversionAction =
                ResourceNames.ConversionAction(customerId, conversionActionId)
        });
    }

    // Creates a basic user list info object with all of the conversion actions.
    BasicUserListInfo basicUserListInfo = new BasicUserListInfo();
    basicUserListInfo.Actions.Add(userListActionInfoList);

    // Creates the basic user list.
    UserList basicUserList = new UserList
    {
        Name = $"Example BasicUserList #{ExampleUtilities.GetShortRandomString()}",
        Description = "A list of people who have triggered one or more conversion actions",
        MembershipLifeSpan = 365L,
        BasicUserList = basicUserListInfo,
        MembershipStatus = UserListMembershipStatus.Open
    };

    // Creates the operation.
    UserListOperation operation = new UserListOperation
    {
        Create = basicUserList
    };

    try
    {
        // Adds the new user list.
        MutateUserListsResponse response = userListServiceClient.MutateUserLists
            (customerId.ToString(), new[] { operation });

        // Prints the result.
        Console.WriteLine("Created basic user list with resource name: " +
            $"{response.Results.First().ResourceName}");
    }
    catch (GoogleAdsException e)
    {
        Console.WriteLine("Failure:");
        Console.WriteLine($"Message: {e.Message}");
        Console.WriteLine($"Failure: {e.Failure}");
        Console.WriteLine($"Request ID: {e.RequestId}");
        throw;
    }
}
      

PHP

public static function runExample(
    GoogleAdsClient $googleAdsClient,
    int $customerId,
    array $conversionActionIds
) {
    $userListActionInfoList = [];
    foreach ($conversionActionIds as $conversionActionId) {
        // Creates the UserListActionInfo object for a given conversion action. This specifies
        // the conversion action that, when triggered, will cause a user to be added to a
        // UserList.
        $userListActionInfoList[] = new UserListActionInfo([
            'conversion_action' => ResourceNames::forConversionAction(
                $customerId,
                $conversionActionId
            )
        ]);
    }

    // Creates a basic user list info object with all of the conversion actions.
    $basicUserListInfo = new BasicUserListInfo(['actions' => $userListActionInfoList]);

    // Creates the basic user list.
    $basicUserList = new UserList([
        'name' => 'Example BasicUserList #' . Helper::getPrintableDatetime(),
        'description' => 'A list of people who have triggered one or more conversion actions',
        'membership_status' => UserListMembershipStatus::OPEN,
        'membership_life_span' => 365,
        'basic_user_list' => $basicUserListInfo
    ]);

    // Creates the operation.
    $operation = new UserListOperation();
    $operation->setCreate($basicUserList);

    // Issues a mutate request to add the user list and prints some information.
    $userListServiceClient = $googleAdsClient->getUserListServiceClient();
    $response = $userListServiceClient->mutateUserLists(
        MutateUserListsRequest::build($customerId, [$operation])
    );
    printf(
        "Created basic user list with resource name '%s'.%s",
        $response->getResults()[0]->getResourceName(),
        PHP_EOL
    );
}
在接这个接口时卡住了?
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 每日平台更新简报 →