बदलाव करने के सबसे सही तरीके

Google Ads API में संसाधनों में बदलाव करते समय, परफ़ॉर्मेंस को ऑप्टिमाइज़ करने, सभी कार्रवाइयों में डिपेंडेंसी मैनेज करने, और रिस्पॉन्स मैनेज करने के लिए, इन सबसे सही तरीकों को अपनाएं.

कुछ समय के लिए इस्तेमाल किए जाने वाले संसाधन के नाम

GoogleAdsService.Mutate और BatchJobService, दोनों ही ऐसे अस्थायी संसाधन नामों का इस्तेमाल करते हैं जिन्हें बाद की कार्रवाइयों में रेफ़र किया जा सकता है. इससे, एक ही म्यूटेट अनुरोध या बैच जॉब में, कैंपेन और उससे जुड़े विज्ञापन ग्रुप, विज्ञापन, और कीवर्ड बनाए जा सकते हैं.

अगर आपको एक ही म्यूटेट अनुरोध या बैच जॉब में, हाल ही में बनाए गए किसी संसाधन को रेफ़रंस करना है, तो नए संसाधन के resource_name फ़ील्ड में, नेगेटिव पूर्णांक आईडी (जैसे कि -1 या -2, 0 को छोड़कर) डालें. उदाहरण के लिए, बैच अनुरोध में कैंपेन बनाते समय, उसके संसाधन का नाम customers/CUSTOMER_ID/campaigns/-1 पर सेट करें. एक ही अनुरोध में बाद में कोई विज्ञापन ग्रुप बनाते समय, customers/CUSTOMER_ID/campaigns/-1 को पैरंट कैंपेन के तौर पर रेफ़रंस दें. एपीआई, कैंपेन बनाते समय जनरेट हुए असल कैंपेन आईडी से -1 को अपने-आप बदल देता है.

इस्तेमाल करने से जुड़ी शर्तें

अस्थायी संसाधन के नाम इस्तेमाल करते समय, इन नियमों का ध्यान रखें:

  • क्रम मायने रखता है: किसी अस्थायी संसाधन के नाम का रेफ़रंस सिर्फ़ तब दिया जा सकता है, जब आपने उसे तय कर लिया हो. कार्रवाइयों की सूची में, डिपेंडेंट ऑपरेशन (जैसे कि विज्ञापन ग्रुप बनाना) उस ऑपरेशन के बाद दिखना चाहिए जो इसका पैरंट रिसॉर्स बनाता है (जैसे कि कैंपेन बनाना).
  • एक अनुरोध या बैच-जॉब का स्कोप: अस्थायी संसाधन के नाम, अलग-अलग जॉब या बदलाव के अनुरोधों में बने नहीं रहते. पिछली नौकरी या म्यूटेट अनुरोध में बनाए गए किसी संसाधन का रेफ़रंस देने के लिए, सिस्टम से जनरेट किए गए उसके असली संसाधन का नाम इस्तेमाल करें.
  • ग्लोबल यूनीक होना: किसी एक नौकरी या बदलाव के अनुरोध में, हर अस्थायी संसाधन के नाम के लिए, सभी संसाधन टाइप में एक यूनीक नेगेटिव पूर्णांक का इस्तेमाल करना ज़रूरी है. उदाहरण के लिए, एक ही अनुरोध में किसी कैंपेन और विज्ञापन ग्रुप, दोनों को -1 असाइन नहीं किया जा सकता. एक ही अनुरोध या बैच जॉब में किसी अस्थायी आईडी का दोबारा इस्तेमाल करने पर, NewResourceCreationError.DUPLICATE_TEMP_IDS गड़बड़ी होती है.

पे लोड का उदाहरण

मान लें कि आपको एक ही एपीआई अनुरोध या बैच जॉब में कोई कैंपेन, विज्ञापन ग्रुप, और विज्ञापन जोड़ना है. mutateOperations या BatchJobService.AddBatchJobOperations अनुरोध के पेलोड में, GoogleAdsService.Mutate ऐरे को स्ट्रक्चर किया जा सकता है. इसके लिए, यहां दिए गए REST JSON उदाहरण का इस्तेमाल करें. इसमें, ज़रूरी संसाधन फ़ील्ड को छोटा करके दिखाया गया है:

{
  "mutateOperations": [
    {
      "campaignOperation": {
        "create": {
          "resourceName": "customers/CUSTOMER_ID/campaigns/-1"
        }
      }
    },
    {
      "adGroupOperation": {
        "create": {
          "resourceName": "customers/CUSTOMER_ID/adGroups/-2",
          "campaign": "customers/CUSTOMER_ID/campaigns/-1"
        }
      }
    },
    {
      "adGroupAdOperation": {
        "create": {
          "adGroup": "customers/CUSTOMER_ID/adGroups/-2"
        }
      }
    }
  ]
}

इस उदाहरण में, ये मुख्य बातें बताई गई हैं:

  • विज्ञापन ग्रुप, नए अस्थायी आईडी (-2) का इस्तेमाल करता है, क्योंकि -1 को पहले ही कैंपेन को असाइन किया जा चुका है.
  • विज्ञापन ग्रुप, customers/CUSTOMER_ID/campaigns/-1 को रेफ़रंस देता है, ताकि वह खुद को पिछले ऑपरेशन में बनाए गए कैंपेन से लिंक कर सके.
  • adGroupAdOperation, customers/CUSTOMER_ID/adGroups/-2 को रेफ़रंस देता है और resourceName को शामिल नहीं करता है. ऐसा इसलिए, क्योंकि अनुरोध में बाद की कोई भी कार्रवाई नए विज्ञापन को रेफ़रंस नहीं करती है.

एक जैसी कार्रवाइयों को ग्रुप करना

GoogleAdsService.Mutate का इस्तेमाल करते समय, पैरंट और चाइल्ड डिपेंडेंसी का पालन करते हुए, दोहराए गए mutate_operations ऐरे में संसाधन के टाइप के हिसाब से ग्रुप ऑपरेशन एक साथ करें. यह तरीका, कार्रवाइयों को क्रम से तब तक पढ़ता है, जब तक उसे किसी दूसरे संसाधन टाइप का सामना नहीं करना पड़ता. इसके बाद, यह एक ही तरह की सभी कार्रवाइयों को एक साथ एक बैकएंड सेवा अनुरोध में बैच करता है.

उदाहरण के लिए, अगर आपने दोहराए गए mutate_operations फ़ील्ड में, कैंपेन से जुड़ी पांच कार्रवाइयों के बाद विज्ञापन ग्रुप से जुड़ी 10 कार्रवाइयां शामिल की हैं, तो सिस्टम बैकएंड में दो कॉल करेगा: पहला कॉल, कैंपेन से जुड़ी पांच कार्रवाइयों के लिए CampaignService को किया जाएगा. वहीं, दूसरा कॉल, विज्ञापन ग्रुप से जुड़ी 10 कार्रवाइयों के लिए AdGroupService को किया जाएगा.

इसके उलट, [campaign, ad group, campaign, ad group] के तौर पर ऑर्डर करके इंटरलीविंग ऑपरेशन करने से, बैकएंड में चार अलग-अलग कॉल होते हैं. इंटरलीव किए गए कॉल से, एपीआई की परफ़ॉर्मेंस पर असर पड़ता है. साथ ही, बड़े बैच में अनुरोधों के टाइम आउट होने की समस्या आ सकती है.

कुछ फ़ाइलों का फ़ॉर्मैट नहीं बदला जा सका और बैच की सीमाएं

डिफ़ॉल्ट रूप से, अगर कोई एक ऑपरेशन पूरा नहीं होता है, तो GoogleAdsService.Mutate पूरे अनुरोध को रोल बैक कर देता है. अगर एक ही अनुरोध में मौजूद अन्य कार्रवाइयां पूरी नहीं होती हैं, तब भी मान्य कार्रवाइयां पूरी करने के लिए, अनुरोध में partial_failure को true पर सेट करें. साथ ही, जवाब में partial_failure_error की जांच करें. जब partial_failure true होता है, तब अगर किसी पैरंट ऑपरेशन में तय किया गया अस्थायी आईडी (जैसे कि customers/CUSTOMER_ID/campaigns/-1) मान्य नहीं होता है, तो उसी अनुरोध में उस अस्थायी आईडी का रेफ़रंस देने वाले सभी डिपेंडेंट चाइल्ड ऑपरेशन भी NewResourceCreationError.TEMP_ID_RESOURCE_HAD_ERRORS के साथ मान्य नहीं होते हैं. ज़्यादा जानकारी के लिए, आंशिक तौर पर फ़ेल होने की गाइड देखें.

अनुरोध के साइज़, सब-बैचिंग, और दर की सीमाओं का भी ध्यान रखें:

  • अनुरोध और चंक के साइज़ की सीमाएं: एक GoogleAdsService.Mutate अनुरोध में, ज़्यादा से ज़्यादा 10,000 म्यूटेट ऑपरेशन किए जा सकते हैं. अगर अनुरोध में सभी ऑपरेशन AdGroupCriterionOperation हैं, तो ज़्यादा से ज़्यादा 20,000 म्यूटेट ऑपरेशन किए जा सकते हैं. अगर इससे ज़्यादा ऑपरेशन किए जाते हैं, तो RequestError.TOO_MANY_MUTATE_OPERATIONS दिखता है. इसके अलावा, ज़्यादा से ज़्यादा 100 ऐक्शन ऑपरेशन (RequestError.TOO_MANY_ACTION_OPERATIONS) किए जा सकते हैं. BatchJobService.AddBatchJobOperations के तहत, हर कॉल में ज़्यादा से ज़्यादा 10,000 ऑपरेशन किए जा सकते हैं. साथ ही, हर MutateOperation में ज़्यादा से ज़्यादा 10,484,504 बाइट और हर AddBatchJobOperationsRequest में ज़्यादा से ज़्यादा 41,937,920 बाइट इस्तेमाल किए जा सकते हैं. अगर किसी भी सीमा का उल्लंघन होता है, तो BatchJobError.REQUEST_TOO_LARGE दिखता है. साथ ही, हर बैच जॉब में कुल 10,00,000 ऑपरेशन किए जा सकते हैं. एक ही कैंपेन या खाते को टारगेट करने वाले एक साथ कई बदलावों की वजह से, DatabaseError.CONCURRENT_MODIFICATION गड़बड़ियां हो सकती हैं.
  • BatchJobService एटॉमिक सब-बैचिंग: बैच जॉब, आंशिक तौर पर फ़ेल होने के सिमैंटिक के तहत काम करते हैं. डिफ़ॉल्ट रूप से, हर इंटरनल सब-बैच में 1,000 ऑपरेशन होते हैं. हालांकि, BatchJobService एक ही पैरंट आईडी के लिए, एक साथ किए जाने वाले कुछ डिपेंडेंट ऑपरेशन को अपने-आप एटॉमिक सब-बैच में ग्रुप कर देता है:
    • एक AssetGroupOperation (create) के बाद, एक ही AssetGroup आईडी के लिए लगातार AssetGroupAssetOperation (create) कार्रवाइयां (कुल 1,000 कार्रवाइयां, BatchJobError.ASSET_GROUP_AND_ASSET_GROUP_ASSET_TRANSACTION_FAILURE के साथ एटॉमिक रूप से फ़ेल हो जाती हैं; हर AssetGroupOperation update या remove, एक ही कार्रवाई वाले स्टैंडअलोन सब-बैच में काम करता है).
    • परफ़ॉर्मेंस मैक्स कैंपेन CampaignOperation (create, जब ब्रैंड के दिशा-निर्देश चालू हों—यह डिफ़ॉल्ट रूप से चालू होता है, जब तक कि brand_guidelines_enabled को false पर सेट न किया गया हो या hotel_property_asset_set को सेट न किया गया हो). इसके बाद, एक ही Campaign आईडी के लिए लगातार CampaignAssetOperation (create) कार्रवाइयां की जाती हैं. कुल 1,000 कार्रवाइयां की जा सकती हैं. ऐसा न होने पर, BatchJobError.CAMPAIGN_AND_CAMPAIGN_ASSET_TRANSACTION_FAILURE के साथ एटॉमिक रूप से कार्रवाइयां नहीं हो पाती हैं.
    • एक ही पैरंट (AssetGroup या AdGroup) के लिए, लगातार AssetGroupListingGroupFilterOperation (max 10,000, BatchJobError.ASSET_GROUP_LISTING_GROUP_FILTER_TRANSACTION_FAILURE के साथ एटॉमिक तौर पर फ़ेल होना) या AdGroupCriterionOperation (listing_group, max 20,000, CriterionError.LISTING_GROUP_ERROR_IN_ANOTHER_OPERATION के साथ एटॉमिक तौर पर फ़ेल होना) कार्रवाइयां.

जवाब से बदले जा सकने वाले एट्रिब्यूट वापस पाना

अगर आपने म्यूटेट अनुरोध के response_content_type को MUTABLE_RESOURCE पर सेट किया है, तो जवाब में resource_name और संसाधन ऑब्जेक्ट शामिल होता है. संसाधन ऑब्जेक्ट में, बदले जा सकने वाले फ़ील्ड शामिल होते हैं. साथ ही, इसमें सिस्टम से अपने-आप भरे गए मुख्य फ़ील्ड भी शामिल होते हैं. जैसे, ExperimentArm.in_design_campaigns. यह जानकारी, अनुरोध से बनाए गए या अपडेट किए गए (हटाए नहीं गए) हर ऑब्जेक्ट के लिए होती है. remove कार्रवाइयों के लिए या ऐसे संसाधन टाइप के लिए जो MUTABLE_RESOURCE को वापस लाने की सुविधा नहीं देते हैं, जवाब में हमेशा सिर्फ़ resource_name दिखता है. इस सुविधा का इस्तेमाल करके, हर म्यूटेट कॉल के बाद अतिरिक्त Search या SearchStream अनुरोध भेजने से बचें.

साथ ही, ज़रूरत न होने पर इसे बहुत बड़े बैच पर चालू न करें.

अगर आपने response_content_type सेट नहीं किया है, तो Google Ads API डिफ़ॉल्ट रूप से RESOURCE_NAME_ONLY पर सेट हो जाता है. साथ ही, यह सिर्फ़ बदले गए हर संसाधन का resource_name दिखाता है.

यहां दिए गए उदाहरण में, म्यूटेट कॉल से बदले जा सकने वाले संसाधन को वापस पाने का तरीका बताया गया है:

Java

private String createExperimentArms(
    GoogleAdsClient googleAdsClient, long customerId, long campaignId, String experiment) {
  List<ExperimentArmOperation> operations = new ArrayList<>();
  operations.add(
      ExperimentArmOperation.newBuilder()
          .setCreate(
              // The "control" arm references an already-existing campaign.
              ExperimentArm.newBuilder()
                  .setControl(true)
                  .addCampaigns(ResourceNames.campaign(customerId, campaignId))
                  .setExperiment(experiment)
                  .setName("control arm")
                  .setTrafficSplit(40)
                  .build())
          .build());
  operations.add(
      ExperimentArmOperation.newBuilder()
          .setCreate(
              // In standard campaign experiments, creating the treatment arm automatically
              // generates a draft campaign that you can modify before starting the experiment.
              ExperimentArm.newBuilder()
                  .setControl(false)
                  .setExperiment(experiment)
                  .setName("experiment arm")
                  .setTrafficSplit(60)
                  .build())
          .build());

  try (ExperimentArmServiceClient experimentArmServiceClient =
      googleAdsClient.getLatestVersion().createExperimentArmServiceClient()) {
    // Constructs the mutate request.
    MutateExperimentArmsRequest mutateRequest =
        MutateExperimentArmsRequest.newBuilder()
            .setCustomerId(Long.toString(customerId))
            .addAllOperations(operations)
            // We want to fetch the draft campaign IDs from the treatment arm, so the easiest way
            // to do that is to have the response return the newly created entities.
            .setResponseContentType(ResponseContentType.MUTABLE_RESOURCE)
            .build();

    // Sends the mutate request.
    MutateExperimentArmsResponse response =
        experimentArmServiceClient.mutateExperimentArms(mutateRequest);

    // Results always return in the order that you specify them in the request. Since we created
    // the treatment arm last, it will be the last result.  If you don't remember which arm is the
    // treatment arm, you can always filter the query in the next section with
    // `experiment_arm.control = false`.
    MutateExperimentArmResult controlArmResult = response.getResults(0);
    MutateExperimentArmResult treatmentArmResult =
        response.getResults(response.getResultsCount() - 1);

    System.out.printf(
        "Created control arm with resource name '%s'%n", controlArmResult.getResourceName());
    System.out.printf(
        "Created treatment arm with resource name '%s'%n", treatmentArmResult.getResourceName());

    return treatmentArmResult.getExperimentArm().getInDesignCampaigns(0);
  }
}

      

C#

private static (MutateExperimentArmResult, MutateExperimentArmResult)
    CreateExperimentArms(GoogleAdsClient client, long customerId, long baseCampaignId,
        string experimentResourceName)
{
    // Get the ExperimentArmService.
    ExperimentArmServiceClient experimentService = client.GetService(
        Services.V25.ExperimentArmService);

    // Create the control arm. The control arm references an already-existing campaign.
    ExperimentArmOperation controlArmOperation = new ExperimentArmOperation()
    {
        Create = new ExperimentArm()
        {
            Control = true,
            Campaigns = {
                ResourceNames.Campaign(customerId, baseCampaignId)
            },
            Experiment = experimentResourceName,
            Name = "Control Arm",
            TrafficSplit = 40
        }
    };

    // Create the non-control arm.
    // In standard campaign experiments, creating the treatment arm automatically
    // generates a draft campaign that you can modify before starting the experiment.
    ExperimentArmOperation treatmentArmOperation = new ExperimentArmOperation()
    {
        Create = new ExperimentArm()
        {
            Control = false,
            Experiment = experimentResourceName,
            Name = "Experiment Arm",
            TrafficSplit = 60
        }
    };

    // We want to fetch the draft campaign IDs from the treatment arm, so the
    // easiest way to do that is to have the response return the newly created
    // entities.
    MutateExperimentArmsRequest request = new MutateExperimentArmsRequest
    {
        CustomerId = customerId.ToString(),
        Operations = { controlArmOperation, treatmentArmOperation },
        ResponseContentType = ResponseContentType.MutableResource
    };

    MutateExperimentArmsResponse response = experimentService.MutateExperimentArms(
        request
    );

    // Results always return in the order that you specify them in the request.
    // Since we created the treatment arm last, it will be the last result.
    MutateExperimentArmResult controlArm = response.Results.First();
    MutateExperimentArmResult treatmentArm = response.Results.Last();

    Console.WriteLine($"Created control arm with resource name " +
        $"'{controlArm.ResourceName}'.");
    Console.WriteLine($"Created treatment arm with resource name" +
      $" '{treatmentArm.ResourceName}'.");
    return (controlArm, treatmentArm);
}
      

PHP

private static function createExperimentArms(
    GoogleAdsClient $googleAdsClient,
    int $customerId,
    int $campaignId,
    string $experimentResourceName
): string {
    $operations = [];
    $experimentArm1 = new ExperimentArm(
        [
        // The "control" arm references an already-existing campaign.
        'control' => true,
        'campaigns' => [ResourceNames::forCampaign($customerId, $campaignId)],
        'experiment' => $experimentResourceName,
        'name' => 'control arm',
        'traffic_split' => 40
        ]
    );
    $operations[] = new ExperimentArmOperation(['create' => $experimentArm1]);
    $experimentArm2 = new ExperimentArm(
        [
        // The non-"control" arm, also called a "treatment" arm, will automatically
        // generate draft campaigns that you can modify before starting the
        // experiment.
        'control' => false,
        'experiment' => $experimentResourceName,
        'name' => 'experiment arm',
        'traffic_split' => 60
        ]
    );
    $operations[] = new ExperimentArmOperation(['create' => $experimentArm2]);

    // Issues a request to create the experiment arms.
    $experimentArmServiceClient = $googleAdsClient->getExperimentArmServiceClient();
    $response = $experimentArmServiceClient->mutateExperimentArms(
        MutateExperimentArmsRequest::build($customerId, $operations)
            // We want to fetch the draft campaign IDs from the treatment arm, so the easiest
            // way to do that is to have the response return the newly created entities.
            ->setResponseContentType(ResponseContentType::MUTABLE_RESOURCE)
    );
    // Results always return in the order that you specify them in the request.
    // Since we created the treatment arm last, it will be the last result.
    $controlArmResourceName = $response->getResults()[0]->getResourceName();
    $treatmentArm = $response->getResults()[count($operations) - 1];
    print "Created control arm with resource name '$controlArmResourceName'" . PHP_EOL;
    print "Created treatment arm with resource name '{$treatmentArm->getResourceName()}'"
        . PHP_EOL;

    return $treatmentArm->getExperimentArm()->getInDesignCampaigns()[0];
}
      

Python

def create_experiment_arms(
    client: GoogleAdsClient,
    customer_id: str,
    base_campaign_id: str,
    experiment: str,
) -> str:
    """Creates a control and treatment experiment arms.

    Args:
        client: an initialized GoogleAdsClient instance.
        customer_id: a client customer ID.
        base_campaign_id: the campaign ID to associate with the control arm of
          the experiment.
        experiment: the resource name for an experiment.

    Returns:
        the resource name for the new treatment experiment arm.
    """
    operations: List[ExperimentArmOperation] = []

    campaign_service: CampaignServiceClient = client.get_service(
        "CampaignService"
    )

    # The "control" arm references an already-existing campaign.
    operation_1: ExperimentArmOperation = client.get_type(
        "ExperimentArmOperation"
    )
    exa_1: ExperimentArm = operation_1.create
    exa_1.control = True
    exa_1.campaigns.append(
        campaign_service.campaign_path(customer_id, base_campaign_id)
    )
    exa_1.experiment = experiment
    exa_1.name = "control arm"
    exa_1.traffic_split = 40
    operations.append(operation_1)

    # In standard campaign experiments, creating the treatment arm automatically
    # generates a draft campaign that you can modify before starting the experiment.
    operation_2: ExperimentArmOperation = client.get_type(
        "ExperimentArmOperation"
    )
    exa_2: ExperimentArm = operation_2.create
    exa_2.control = False
    exa_2.experiment = experiment
    exa_2.name = "experiment arm"
    exa_2.traffic_split = 60
    operations.append(operation_2)

    experiment_arm_service: ExperimentArmServiceClient = client.get_service(
        "ExperimentArmService"
    )
    request: MutateExperimentArmsRequest = client.get_type(
        "MutateExperimentArmsRequest"
    )
    request.customer_id = customer_id
    request.operations = operations
    # We want to fetch the draft campaign IDs from the treatment arm, so the
    # easiest way to do that is to have the response return the newly created
    # entities.
    request.response_content_type = (
        client.enums.ResponseContentTypeEnum.MUTABLE_RESOURCE
    )
    response: MutateExperimentArmsResponse = (
        experiment_arm_service.mutate_experiment_arms(request=request)
    )

    # Results always return in the order that you specify them in the request.
    # Since we created the treatment arm second, it will be the second result.
    control_arm_result: Any = response.results[0]
    treatment_arm_result: Any = response.results[1]

    print(
        f"Created control arm with resource name {control_arm_result.resource_name}"
    )
    print(
        f"Created treatment arm with resource name {treatment_arm_result.resource_name}"
    )

    return treatment_arm_result.experiment_arm.in_design_campaigns[0]
      

Ruby

def create_experiment_arms(client, customer_id, base_campaign_id, experiment)
  operations = []
  operations << client.operation.create_resource.experiment_arm do |ea|
    # The "control" arm references an already-existing campaign.
    ea.control = true
    ea.campaigns << client.path.campaign(customer_id, base_campaign_id)
    ea.experiment = experiment
    ea.name = 'control arm'
    ea.traffic_split = 40
  end
  operations << client.operation.create_resource.experiment_arm do |ea|
    # The non-"control" arm, also called a "treatment" arm, will automatically
    # generate draft campaigns that you can modify before starting the
    # experiment.
    ea.control = false
    ea.experiment = experiment
    ea.name = 'experiment arm'
    ea.traffic_split = 60
  end

  response = client.service.experiment_arm.mutate_experiment_arms(
    customer_id: customer_id,
    operations: operations,
    # We want to fetch the draft campaign IDs from the treatment arm, so the
    # easiest way to do that is to have the response return the newly created
    # entities.
    response_content_type: :MUTABLE_RESOURCE,
  )

  # Results always return in the order that you specify them in the request.
  # Since we created the treatment arm last, it will be the last result.
  control_arm_result = response.results.first
  treatment_arm_result = response.results.last

  puts "Created control arm with resource name #{control_arm_result.resource_name}."
  puts "Created treatment arm with resource name #{treatment_arm_result.resource_name}."

  treatment_arm_result.experiment_arm.in_design_campaigns.first
end
      

Perl

sub create_experiment_arms {
  my ($api_client, $customer_id, $base_campaign_id, $experiment) = @_;

  my $operations = [];
  push @$operations,
    Google::Ads::GoogleAds::V25::Services::ExperimentArmService::ExperimentArmOperation
    ->new({
      create => Google::Ads::GoogleAds::V25::Resources::ExperimentArm->new({
          # The "control" arm references an already-existing campaign.
          control   => "true",
          campaigns => [
            Google::Ads::GoogleAds::V25::Utils::ResourceNames::campaign(
              $customer_id, $base_campaign_id
            )
          ],
          experiment   => $experiment,
          name         => "control arm",
          trafficSplit => 40
        })});

  push @$operations,
    Google::Ads::GoogleAds::V25::Services::ExperimentArmService::ExperimentArmOperation
    ->new({
      create => Google::Ads::GoogleAds::V25::Resources::ExperimentArm->new({
          # The non-"control" arm, also called a "treatment" arm, will automatically
          # generate draft campaigns that you can modify before starting the
          # experiment.
          control      => "false",
          experiment   => $experiment,
          name         => "experiment arm",
          trafficSplit => 60
        })});

  my $response = $api_client->ExperimentArmService()->mutate({
    customerId => $customer_id,
    operations => $operations,
    # We want to fetch the draft campaign IDs from the treatment arm, so the
    # easiest way to do that is to have the response return the newly created
    # entities.
    responseContentType => MUTABLE_RESOURCE
  });

  # Results always return in the order that you specify them in the request.
  # Since we created the treatment arm last, it will be the last result.
  my $control_arm_result   = $response->{results}[0];
  my $treatment_arm_result = $response->{results}[1];

  printf "Created control arm with resource name '%s'.\n",
    $control_arm_result->{resourceName};
  printf "Created treatment arm with resource name '%s'.\n",
    $treatment_arm_result->{resourceName};
  return $treatment_arm_result->{experimentArm}{inDesignCampaigns}[0];
}
      

curl