系统管理的实验用于通过创建与原始对照组广告系列一起投放的一个或多个可修改的实验组广告系列来对更改进行 A/B 测试。此工作流支持以下 ExperimentType 值:
SEARCH_CUSTOM:包含搜索广告系列的自定义实验。DISPLAY_CUSTOM:包含展示广告系列的自定义实验。HOTEL_CUSTOM:包含酒店广告系列的自定义实验。YOUTUBE_CUSTOM:包含视频广告系列的自定义实验。PMAX_REPLACEMENT_SHOPPING:一种实验,用于测试购物广告系列与效果最大化广告系列相比效果如何。
设置
系统管理的实验的设置遵循以下步骤:
- 创建
Experiment。 - 为对照组和实验组创建
ExperimentArm资源。 - 修改实验组中的
in_design_campaigns。
1. 创建实验
使用 Google Ads API 运行实验的第一步是创建 Experiment。此资源定义了您要运行的实验的一些关键信息。在此步骤中,您无需指定参与实验的任何广告系列。
以下是 Experiment 的一些关键字段的概览:
name:每个实验都必须具有唯一的名称。description:一个可选字段,可供您日后引用。不会影响实验的运行方式。suffix:后缀将附加到实验组广告系列名称的末尾,以便您将它们与对照组广告系列区分开来。 我们将在第 2 步中进一步说明这些概念。type:要运行的实验类型。对于系统管理的实验,请使用SEARCH_CUSTOM、DISPLAY_CUSTOM、HOTEL_CUSTOM、YOUTUBE_CUSTOM或PMAX_REPLACEMENT_SHOPPING。status:创建实验时,请将此字段设置为SETUP。稍后,当您开始实验后,此字段将用于查看当前状态。start_date和end_date:指定实验的开始时间和结束时间。sync_enabled:默认处于停用状态。如果设置为true,则在实验运行期间对原始广告系列所做的更改会自动复制到实验广告系列。了解详情。
Java
private String createExperimentResource(GoogleAdsClient googleAdsClient, long customerId) { ExperimentOperation operation = ExperimentOperation.newBuilder() .setCreate( Experiment.newBuilder() // Name must be unique. .setName("Example Experiment #" + getPrintableDateTime()) // We specify SEARCH_CUSTOM to create a standard search campaign experiment. // This type uses a standard draft-based workflow where the system automatically // creates a draft/in-design campaign for the treatment arm. .setType(ExperimentType.SEARCH_CUSTOM) .setSuffix("[experiment]") .setStatus(ExperimentStatus.SETUP) .build()) .build(); try (ExperimentServiceClient experimentServiceClient = googleAdsClient.getLatestVersion().createExperimentServiceClient()) { MutateExperimentsResponse response = experimentServiceClient.mutateExperiments( Long.toString(customerId), ImmutableList.of(operation)); String experiment = response.getResults(0).getResourceName(); System.out.printf("Created experiment with resource name '%s'%n", experiment); return experiment; } }
C#
private static string CreateExperimentResource(GoogleAdsClient client, long customerId) { // Get the ExperimentService. ExperimentServiceClient experimentService = client.GetService( Services.V25.ExperimentService); // Creates the experiment. Experiment experiment = new Experiment() { // Name must be unique. Name = $"Example Experiment #{ExampleUtilities.GetRandomString()}", // We specify SearchCustom to create a standard search campaign experiment. // This type uses a standard draft-based workflow where the system automatically // creates a draft/in-design campaign for the treatment arm. Type = ExperimentType.SearchCustom, Suffix = "[experiment]", Status = ExperimentStatus.Setup }; // Creates the operation. ExperimentOperation operation = new ExperimentOperation() { Create = experiment }; // Makes the API call. MutateExperimentsResponse response = experimentService.MutateExperiments( customerId.ToString(), new[] { operation }); // Displays the result. string experimentResourceName = response.Results.First().ResourceName; Console.WriteLine($"Created experiment with resource name " + $"'{experimentResourceName}'."); return experimentResourceName; }
PHP
private static function createExperimentResource( ExperimentServiceClient $experimentServiceClient, int $customerId ): string { // Creates an experiment and its operation. $experiment = new Experiment([ // Name must be unique. 'name' => 'Example Experiment #' . Helper::getPrintableDatetime(), 'type' => ExperimentType::SEARCH_CUSTOM, 'suffix' => '[experiment]', 'status' => ExperimentStatus::SETUP ]); $experimentOperation = new ExperimentOperation(['create' => $experiment]); // Issues a request to create the experiment. $response = $experimentServiceClient->mutateExperiments( MutateExperimentsRequest::build($customerId, [$experimentOperation]) ); $experimentResourceName = $response->getResults()[0]->getResourceName(); print "Created experiment with resource name '$experimentResourceName'" . PHP_EOL; return $experimentResourceName; }