실험은 기본 캠페인과 관련된 실험 캠페인을 관리하는 인터페이스입니다. 실험 캠페인은 광고를 게재하고 클릭수, 비용, 기타 측정항목을 누적할 수 있는 본격적인 캠페인입니다.
Google Ads API를 사용하여 실험을 실행하는 첫 번째 단계는 Experiment
를 만드는 것입니다. 이 리소스는 실행하려는 실험에 관한 몇 가지 주요 정보를 정의합니다(예: 이름, 실험 유형). 이 단계에서는 실험에 참여하는 캠페인을 지정하지 않습니다.
다음은 Experiment
의 몇 가지 주요 필드에 대한 개요입니다.
name
: 각 실험에는 고유한 이름이 있어야 합니다.description
: 나중에 참조하는 데 사용할 수 있는 선택적 필드입니다. 실험 실행 방식에는 영향을 미치지 않습니다.suffix
: 실험군 캠페인을 대조군 캠페인과 구분할 수 있도록 실험군 캠페인 이름 끝에 접미사가 추가됩니다. 이러한 개념은 실험 부문 페이지에서 자세히 설명합니다.type
: 실행할 실험 유형입니다. 여기에는 다양한 유형이 있지만 대부분은 시스템 실험입니다. 맞춤 실험의 경우SEARCH_CUSTOM
또는DISPLAY_CUSTOM
를 지정해야 합니다.status
: 실험을 만들 때 이 필드를SETUP
로 설정합니다. 나중에 실험을 시작하면 이 필드를 통해 현재 실행 중인 작업을 확인할 수 있습니다.start_date
및end_date
: 실험 시작 및 종료 시간을 지정합니다.sync_enabled
: 기본적으로 사용 중지됩니다.true
로 설정하면 실험이 진행되는 동안 기존 캠페인에 적용되는 변경사항이 실험 캠페인에 자동으로 복사됩니다. 자세히 알아보기
다음은 실험을 만드는 예입니다.
private String createExperimentResource(GoogleAdsClient googleAdsClient, long customerId) { ExperimentOperation operation = ExperimentOperation.newBuilder() .setCreate( Experiment.newBuilder() // Name must be unique. .setName("Example Experiment #" + getPrintableDateTime()) .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; } }
/// <summary> /// Creates the experiment. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The customer ID for which the call is made.</param> /// <returns>The resource name of the newly created experiment.</returns> private static string CreateAnExperiment(GoogleAdsClient client, long customerId) { // Get the ExperimentService. ExperimentServiceClient experimentService = client.GetService( Services.V19.ExperimentService); // Creates the experiment. Experiment experiment = new Experiment() { // Name must be unique. Name = $"Example Experiment #{ExampleUtilities.GetRandomString()}", 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; }
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; }
def create_experiment_resource(client, customer_id): """Creates a new experiment resource. Args: client: an initialized GoogleAdsClient instance. customer_id: a client customer ID. Returns: the resource name for the new experiment. """ experiment_operation = client.get_type("ExperimentOperation") experiment = experiment_operation.create experiment.name = f"Example Experiment #{uuid.uuid4()}" experiment.type_ = client.enums.ExperimentTypeEnum.SEARCH_CUSTOM experiment.suffix = "[experiment]" experiment.status = client.enums.ExperimentStatusEnum.SETUP experiment_service = client.get_service("ExperimentService") response = experiment_service.mutate_experiments( customer_id=customer_id, operations=[experiment_operation] ) experiment_resource_name = response.results[0].resource_name print(f"Created experiment with resource name {experiment_resource_name}") return experiment_resource_name
def create_experiment_resource(client, customer_id) operation = client.operation.create_resource.experiment do |e| # Name must be unique. e.name = "Example Experiment #{(Time.new.to_f * 1000).to_i}" e.type = :SEARCH_CUSTOM e.suffix = '[experiment]' e.status = :SETUP end response = client.service.experiment.mutate_experiments( customer_id: customer_id, operations: [operation], ) experiment = response.results.first.resource_name puts "Created experiment with resource name #{experiment}." experiment end
sub create_experiment_resource { my ($api_client, $customer_id) = @_; my $experiment = Google::Ads::GoogleAds::V19::Resources::Experiment->new({ # Name must be unique. name => "Example Experiment #" . uniqid(), type => SEARCH_CUSTOM, suffix => "[experiment]", status => SETUP }); my $operation = Google::Ads::GoogleAds::V19::Services::ExperimentService::ExperimentOperation ->new({ create => $experiment }); my $response = $api_client->ExperimentService()->mutate({ customerId => $customer_id, operations => [$operation]}); my $resource_name = $response->{results}[0]{resourceName}; printf "Created experiment with resource name '%s'.\n", $resource_name; return $resource_name; }