कन्वर्ज़न में बदलाव अपलोड करें

Google Ads में कन्वर्ज़न की रिपोर्ट पहले ही दे दिए जाने के बाद, आप Google Ads में बदलाव के कन्वर्ज़न को बाद के किसी समय में Google Ads API में समय.

कन्वर्ज़न में बदलाव करने के लिए, पहले आपके पास कन्वर्ज़न कार्रवाई सेट होना चाहिए बढ़ सकता है और आपके पास उन कन्वर्ज़न को रिकॉर्ड किया गया हो जिन्हें आप अडजस्ट करने वाले हैं.

कोड का उदाहरण

Google Ads API, order_id का इस्तेमाल करता है. इसे ट्रांज़ैक्शन आईडी भी कहा जाता है. इसकी मदद से, ConversionAdjustmentUploadService के साथ अडजस्ट करने के लिए कन्वर्ज़न की पहचान की जाती है.

कन्वर्ज़न में बदलाव करने के लिए ज़रूरी conversion_action_id पाने के लिए, इनमें से कोई एक काम करें:

  • यूआरएल में मौजूद ctId पैरामीटर से वैल्यू पाएं, जब Google Ads यूज़र इंटरफ़ेस (यूआई) में कन्वर्ज़न की जानकारी पर क्लिक करें.

  • conversion_action में मौजूद conversion_action.id के लिए, Google Ads API की क्वेरी इस्तेमाल करें रिपोर्ट.

Java

private void runExample(
    GoogleAdsClient googleAdsClient,
    long customerId,
    long conversionActionId,
    String orderId,
    String adjustmentType,
    String adjustmentDateTime,
    @Nullable Float restatementValue)
    throws InvalidProtocolBufferException {
  // Gets the conversion adjustment enum value from the adjustmentType String.
  ConversionAdjustmentType conversionAdjustmentType =
      ConversionAdjustmentType.valueOf(adjustmentType);

  // Applies the conversion adjustment to the existing conversion.
  ConversionAdjustment conversionAdjustment =
      ConversionAdjustment.newBuilder()
          .setConversionAction(ResourceNames.conversionAction(customerId, conversionActionId))
          .setAdjustmentType(conversionAdjustmentType)
          // Sets the orderId to identify the conversion to adjust.
          .setOrderId(orderId)
          // As an alternative to setting orderId, you can provide a GclidDateTimePair, but
          // setting orderId instead is strongly recommended.
          // .setGclidDateTimePair(
          //     GclidDateTimePair.newBuilder()
          //         .setGclid(gclid)
          //         .setConversionDateTime(conversionDateTime)
          //         .build())
          .setAdjustmentDateTime(adjustmentDateTime)
          .build();

  // Sets adjusted value for adjustment type RESTATEMENT.
  if (restatementValue != null
      && conversionAdjustmentType == ConversionAdjustmentType.RESTATEMENT) {
    conversionAdjustment =
        conversionAdjustment.toBuilder()
            .setRestatementValue(
                RestatementValue.newBuilder().setAdjustedValue(restatementValue).build())
            .build();
  }

  // Creates the conversion upload service client.
  try (ConversionAdjustmentUploadServiceClient conversionUploadServiceClient =
      googleAdsClient.getLatestVersion().createConversionAdjustmentUploadServiceClient()) {
    // Uploads the click conversion. Partial failure should always be set to true.
    UploadConversionAdjustmentsRequest request =
        UploadConversionAdjustmentsRequest.newBuilder()
            .setCustomerId(Long.toString(customerId))
            // Enables partial failure (must be true).
            .setPartialFailure(true)
            .addConversionAdjustments(conversionAdjustment)
            .build();
    UploadConversionAdjustmentsResponse response =
        conversionUploadServiceClient.uploadConversionAdjustments(request);

    // Extracts the partial failure error if present on the response.
    ErrorUtils errorUtils = ErrorUtils.getInstance();
    GoogleAdsFailure googleAdsFailure =
        response.hasPartialFailureError()
            ? errorUtils.getGoogleAdsFailure(response.getPartialFailureError())
            : null;

    // Constructs a protocol buffer printer that will print error details in a concise format.
    final Printer errorPrinter = JsonFormat.printer().omittingInsignificantWhitespace();
    // Prints the results for each adjustment, including any partial errors returned.
    for (int opIndex = 0; opIndex < request.getConversionAdjustmentsCount(); opIndex++) {
      ConversionAdjustmentResult result = response.getResults(opIndex);
      if (errorUtils.isPartialFailureResult(result)) {
        // The operation failed. Prints the error details.
        for (GoogleAdsError googleAdsError :
            errorUtils.getGoogleAdsErrors(opIndex, googleAdsFailure)) {
          System.out.printf(
              "%4d: Partial failure occurred: %s%n", opIndex, errorPrinter.print(googleAdsError));
        }
      } else {
        System.out.printf(
            "%4d: Uploaded conversion adjustment for conversion action '%s' and order ID '%s'.%n",
            opIndex, result.getConversionAction(), result.getOrderId());
      }
    }
  }
}
      

C#

public void Run(GoogleAdsClient client, long customerId, long conversionActionId,
    string orderId, string adjustmentDateTime,
    ConversionAdjustmentType adjustmentType,
    double? restatementValue)
{
    // Get the ConversionAdjustmentUploadService.
    ConversionAdjustmentUploadServiceClient conversionAdjustmentUploadService =
        client.GetService(Services.V18.ConversionAdjustmentUploadService);

    // Associate conversion adjustments with the existing conversion action.
    ConversionAdjustment conversionAdjustment = new ConversionAdjustment()
    {
        ConversionAction = ResourceNames.ConversionAction(customerId, conversionActionId),
        AdjustmentType = adjustmentType,
        // Sets the orderId to identify the conversion to adjust.
        OrderId = orderId,
        // As an alternative to setting orderId, you can provide a GclidDateTimePair,
        // but setting orderId instead is strongly recommended.
        //GclidDateTimePair = new GclidDateTimePair()
        //{
        //    Gclid = gclid,
        //    ConversionDateTime = conversionDateTime,
        //},
        AdjustmentDateTime = adjustmentDateTime,
    };

    // Set adjusted value for adjustment type RESTATEMENT.
    if (adjustmentType == ConversionAdjustmentType.Restatement)
    {
        conversionAdjustment.RestatementValue = new RestatementValue()
        {
            AdjustedValue = restatementValue.Value
        };
    }

    try
    {
        // Issue a request to upload the conversion adjustment.
        UploadConversionAdjustmentsResponse response =
            conversionAdjustmentUploadService.UploadConversionAdjustments(
                new UploadConversionAdjustmentsRequest()
                {
                    CustomerId = customerId.ToString(),
                    ConversionAdjustments = { conversionAdjustment },
                    // Enables partial failure (must be true).
                    PartialFailure = true,
                    ValidateOnly = false
                });

        // Prints any partial errors returned.
        // To review the overall health of your recent uploads, see:
        // https://developers.google.com/google-ads/api/docs/conversions/upload-summaries
        if (response.PartialFailureError != null)
        {
            // Extracts the partial failure from the response status.
            GoogleAdsFailure partialFailure = response.PartialFailure;
            Console.WriteLine($"{partialFailure.Errors.Count} partial failure error(s) " +
                $"occurred");
        }
        else
        {
            ConversionAdjustmentResult result = response.Results[0];
            // Print the result.
            Console.WriteLine($"Uploaded conversion adjustment value of" +
                $" '{result.ConversionAction}' for Google Click ID " +
                $"'{result.GclidDateTimePair.Gclid}'");
        }
    }
    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,
    int $conversionActionId,
    string $orderId,
    string $adjustmentType,
    string $adjustmentDateTime,
    ?float $restatementValue
) {
    $conversionAdjustmentType = ConversionAdjustmentType::value($adjustmentType);

    // Applies the conversion adjustment to the existing conversion.
    $conversionAdjustment = new ConversionAdjustment([
        'conversion_action' =>
            ResourceNames::forConversionAction($customerId, $conversionActionId),
        'adjustment_type' => $conversionAdjustmentType,
        // Sets the orderId to identify the conversion to adjust.
        'order_id' => $orderId,
        // As an alternative to setting orderId, you can provide a 'gclid_date_time_pair', but
        // setting 'order_id' instead is strongly recommended.
        // 'conversion_date_time' must be in "yyyy-mm-dd hh:mm:ss+|-hh:mm" format.
        /*
        'gclid_date_time_pair' => new GclidDateTimePair([
            'gclid' => 'INSERT_YOUR_GCLID_HERE',
            'conversion_date_time' => 'INSERT_YOUR_CONVERSION_DATE_TIME_HERE'
        ]),
        */
        'adjustment_date_time' => $adjustmentDateTime
    ]);

    // Sets adjusted value for adjustment type RESTATEMENT.
    if (
        $restatementValue !== null
        && $conversionAdjustmentType === ConversionAdjustmentType::RESTATEMENT
    ) {
        $conversionAdjustment->setRestatementValue(new RestatementValue([
            'adjusted_value' => $restatementValue
        ]));
    }

    // Issues a request to upload the conversion adjustment.
    $conversionAdjustmentUploadServiceClient =
        $googleAdsClient->getConversionAdjustmentUploadServiceClient();
    $response = $conversionAdjustmentUploadServiceClient->uploadConversionAdjustments(
        // Enables partial failure (must be true).
        UploadConversionAdjustmentsRequest::build($customerId, [$conversionAdjustment], true)
    );

    // Prints the status message if any partial failure error is returned.
    // Note: The details of each partial failure error are not printed here, you can refer to
    // the example HandlePartialFailure.php to learn more.
    if ($response->hasPartialFailureError()) {
        printf(
            "Partial failures occurred: '%s'.%s",
            $response->getPartialFailureError()->getMessage(),
            PHP_EOL
        );
    } else {
        // Prints the result if exists.
        /** @var ConversionAdjustmentResult $uploadedConversionAdjustment */
        $uploadedConversionAdjustment = $response->getResults()[0];
        printf(
            "Uploaded conversion adjustment of '%s' for order ID '%s'.%s",
            $uploadedConversionAdjustment->getConversionAction(),
            $uploadedConversionAdjustment->getOrderId(),
            PHP_EOL
        );
    }
}
      

Python

def main(
    client,
    customer_id,
    conversion_action_id,
    adjustment_type,
    order_id,
    adjustment_date_time,
    restatement_value=None,
):
    """The main method that creates all necessary entities for the example.

    Args:
        client: an initialized GoogleAdsClient instance.
        customer_id: a client customer ID.
        conversion_action_id: the ID of the conversion action to upload the
            adjustment to.
        adjustment_type: the adjustment type, e.g. " "RETRACTION, RESTATEMENT.
        order_id: the transaction ID of the conversion to adjust. Strongly
            recommended instead of using gclid and conversion_date_time.
        adjustment_date_time: the date and time of the adjustment.
        restatement_value: the adjusted value for adjustment type RESTATEMENT.
    """
    conversion_adjustment_type_enum = client.enums.ConversionAdjustmentTypeEnum
    # Determine the adjustment type.
    conversion_adjustment_type = conversion_adjustment_type_enum[
        adjustment_type
    ].value

    # Applies the conversion adjustment to the existing conversion.
    conversion_adjustment = client.get_type("ConversionAdjustment")
    conversion_action_service = client.get_service("ConversionActionService")
    conversion_adjustment.conversion_action = (
        conversion_action_service.conversion_action_path(
            customer_id, conversion_action_id
        )
    )
    conversion_adjustment.adjustment_type = conversion_adjustment_type
    conversion_adjustment.adjustment_date_time = adjustment_date_time

    # Sets the order_id to identify the conversion to adjust.
    conversion_adjustment.order_id = order_id

    # As an alternative to setting order_id, you can provide a
    # gclid_date_time_pair, but setting order_id instead is strongly recommended.
    # conversion_adjustment.gclid_date_time_pair.gclid = gclid
    # conversion_adjustment.gclid_date_time_pair.conversion_date_time = (
    #     conversion_date_time
    # )

    # Sets adjusted value for adjustment type RESTATEMENT.
    if (
        restatement_value
        and conversion_adjustment_type
        == conversion_adjustment_type_enum.RESTATEMENT.value
    ):
        conversion_adjustment.restatement_value.adjusted_value = float(
            restatement_value
        )

    # Uploads the click conversion. Partial failure should always be set to
    # true.
    service = client.get_service("ConversionAdjustmentUploadService")
    request = client.get_type("UploadConversionAdjustmentsRequest")
    request.customer_id = customer_id
    request.conversion_adjustments.append(conversion_adjustment)
    # Enables partial failure (must be true)
    request.partial_failure = True

    response = service.upload_conversion_adjustments(request=request)

    # Extracts the partial failure error if present on the response.
    if response.partial_failure_error:
        error_details = response.partial_failure_error.details

    for i, conversion_adjustment_result in enumerate(response.results):
        # If there's a GoogleAdsFailure in error_details at this position then
        # the uploaded operation failed and we print the error message.
        if error_details and error_details[i]:
            error_detail = error_details[i]
            failure_message = client.get_type("GoogleAdsFailure")
            # Parse the string into a GoogleAdsFailure message instance.
            # To access class-only methods on the message we retrieve its type.
            GoogleAdsFailure = type(failure_message)
            failure_object = GoogleAdsFailure.deserialize(error_detail.value)

            for error in failure_object.errors:
                # Construct and print a string that details which element in
                # the operation list failed (by index number) as well as the
                # error message and error code.
                print(
                    "A partial failure at index "
                    f"{error.location.field_path_elements[0].index} occurred "
                    f"\nError message: {error.message}\nError code: "
                    f"{error.error_code}"
                )
        else:
            print(
                "Uploaded conversion adjustment for conversion action "
                f"'{conversion_adjustment_result.conversion_action}' and order "
                f"ID '{conversion_adjustment_result.order_id}'."
            )
      

Ruby

def upload_conversion_adjustment(
  customer_id,
  conversion_action_id,
  order_id,
  adjustment_type,
  adjustment_date_time,
  restatement_value
)
  # GoogleAdsClient will read a config file from
  # ENV['HOME']/google_ads_config.rb when called without parameters
  client = Google::Ads::GoogleAds::GoogleAdsClient.new

  # Applies the conversion adjustment to the existing conversion.
  conversion_adjustment = client.resource.conversion_adjustment do |ca|
    ca.conversion_action = client.path.conversion_action(customer_id, conversion_action_id)
    ca.adjustment_type = adjustment_type
    ca.order_id = order_id
    ca.adjustment_date_time = adjustment_date_time

    # Set adjusted value for adjustment type RESTATEMENT.
    if adjustment_type == :RESTATEMENT
      ca.restatement_value = client.resource.restatement_value do |ra|
        ra.adjusted_value = restatement_value.to_f
      end
    end
  end

  # Issue a request to upload the conversion adjustment(s).
  response = client.service.conversion_adjustment_upload.upload_conversion_adjustments(
    customer_id: customer_id,
    # This example shows just one adjustment but you may upload multiple ones.
    conversion_adjustments: [conversion_adjustment],
    partial_failure: true
  )

  if response.partial_failure_error.nil?
    # Process and print all results for multiple adjustments
    response.results.each do |result|
      puts "Uploaded conversion adjustment for conversion action #{result.conversion_action} "\
        "and order ID #{result.order_id}."
    end
  else
    # Print any partial errors returned.
    failures = client.decode_partial_failure_error(response.partial_failure_error)
    puts 'Request failed. Failure details:'
    failures.each do |failure|
      failure.errors.each do |error|
        index = error.location.field_path_elements.first.index
        puts "\toperation[#{index}] #{error.error_code.error_code}: #{error.message}"
      end
    end
  end
end
      

Perl

sub upload_conversion_adjustment {
  my ($api_client, $customer_id, $conversion_action_id, $order_id,
    $adjustment_type, $adjustment_date_time, $restatement_value)
    = @_;

  # Applies the conversion adjustment to the existing conversion.
  my $conversion_adjustment =
    Google::Ads::GoogleAds::V18::Services::ConversionAdjustmentUploadService::ConversionAdjustment
    ->new({
      conversionAction =>
        Google::Ads::GoogleAds::V18::Utils::ResourceNames::conversion_action(
        $customer_id, $conversion_action_id
        ),
      adjustmentType => $adjustment_type,
      # Sets the orderId to identify the conversion to adjust.
      orderId => $order_id,
      # As an alternative to setting orderId, you can provide a 'gclid_date_time_pair',
      # but setting 'order_id' instead is strongly recommended.
      # gclidDateTimePair =>
      #  Google::Ads::GoogleAds::V18::Services::ConversionAdjustmentUploadService::GclidDateTimePair
      #  ->new({
      #    gclid              => $gclid,
      #    conversionDateTime => $conversion_date_time
      #  }
      #  ),
      adjustmentDateTime => $adjustment_date_time,
    });

  # Set adjusted value for adjustment type RESTATEMENT.
  $conversion_adjustment->{restatementValue} =
    Google::Ads::GoogleAds::V18::Services::ConversionAdjustmentUploadService::RestatementValue
    ->new({
      adjustedValue => $restatement_value
    }) if defined $restatement_value && $adjustment_type eq RESTATEMENT;

  # Issue a request to upload the conversion adjustment.
  my $upload_conversion_adjustments_response =
    $api_client->ConversionAdjustmentUploadService()
    ->upload_conversion_adjustments({
      customerId            => $customer_id,
      conversionAdjustments => [$conversion_adjustment],
      partialFailure        => "true"
    });

  # Print any partial errors returned.
  if ($upload_conversion_adjustments_response->{partialFailureError}) {
    printf "Partial error encountered: '%s'.\n",
      $upload_conversion_adjustments_response->{partialFailureError}{message};
  }

  # Print the result if valid.
  my $uploaded_conversion_adjustment =
    $upload_conversion_adjustments_response->{results}[0];
  if (%$uploaded_conversion_adjustment) {
    printf "Uploaded conversion adjustment of the conversion action " .
      "with resource name '%s' for order ID '%s'.\n",
      $uploaded_conversion_adjustment->{conversionAction},
      $uploaded_conversion_adjustment->{orderId};
  }

  return 1;
}
      

ज़रूरी शर्तें

एपीआई में कन्वर्ज़न में बदलाव करते समय, इन शर्तों और पाबंदियों का ध्यान रखें:

  • सिर्फ़ वह खाता अडजस्टमेंट अपलोड कर सकता है जो कन्वर्ज़न ऐक्शन मैनेज करता है. कन्वर्ज़न ट्रैकिंग सेटअप करने के निर्देशों का इस्तेमाल करके, यह पता लगाएं कि आपके Google Ads खाते के लिए कौनसा खाता कन्वर्ज़न मैनेज कर रहा है.

    किसी भिन्न खाते के परिणामों का उपयोग करके समायोजन अपलोड करने का प्रयास करने पर NO_CONVERSION_ACTION_FOUND गड़बड़ी. यह गड़बड़ी तब भी दिखती है, जब अडजस्टमेंट का कन्वर्ज़न ऐक्शन चालू न हो.

  • Google Ads, सिर्फ़ SALESFORCE, UPLOAD_CLICKS या WEBPAGE टाइप के कन्वर्ज़न ऐक्शन के लिए कन्वर्ज़न में बदलाव करने की सुविधा देता है. अगर किसी ऐसे कन्वर्ज़न के लिए बदलाव अपलोड करने की कोशिश की जाती है जिसका कन्वर्ज़न ऐक्शन इनमें से किसी एक टाइप का नहीं है, तो आपको INVALID_CONVERSION_ACTION_TYPE वाली गड़बड़ी दिखेगी.

  • तारीख और समय बताने वाले फ़ील्ड में एक ऐसा टाइमज़ोन चाहिए जिसकी ज़रूरत नहीं है उस खाते के ईमेल पते पर हो सकता है. इन फ़ील्ड का फ़ॉर्मैट, yyyy-mm-dd HH:mm:ss+|-HH:mm जैसा होता है. उदाहरण के लिए: 2022-01-01 19:32:45-05:00 (डेलाइट सेविंग टाइम को अनदेखा करना) .

  • कन्वर्ज़न ऐक्शन बनाने के बाद चार से छह घंटे इंतज़ार करें. इसके बाद ही कन्वर्ज़न ऐक्शन में बदलाव करें कन्वर्ज़न की वजह से TOO_RECENT_CONVERSION_ACTION गड़बड़ी.

  • इस वजह से अडजस्टमेंट नहीं हो पाता है CONVERSION_NOT_FOUND गड़बड़ी: अगर इनमें से कोई भी शर्त पूरी होती है:

    • कन्वर्ज़न को कभी रिपोर्ट नहीं किया गया.

    • बदलाव करने की कोशिश से 24 घंटे से कम समय पहले कन्वर्ज़न की सूचना दी गई थी. कुछ परिस्थितियों में, इसकी वजह से TOO_RECENT_CONVERSION नहीं होना चाहिए.

  • आपको इनमें से किसी भी स्थिति में, ConversionAdjustment में order_id की वैल्यू देनी होगी:

    • कन्वर्ज़न ऐक्शन का type, WEBPAGE के बराबर है.

    • जिस मूल कन्वर्ज़न में बदलाव किया जा रहा है उसे order_id असाइन किया गया है.

    अगर इसके बजाय gclid_date_time_pair का इस्तेमाल किया जाता है, तो कार्रवाई ConversionAdjustmentUploadError.MISSING_ORDER_ID_FOR_WEBPAGE या ConversionAdjustmentUploadError.CONVERSION_NOT_FOUND गड़बड़ी के साथ पूरी नहीं होगी.

  • ConversionAdjustment बनाते समय, इसकी partial_failure एट्रिब्यूट यह UploadConversionAdjustmentsRequest हमेशा true पर सेट होना चाहिए. मान्य और अमान्य ऑपरेशन को एक साथ मैनेज करते समय, कुछ ऑपरेशन के पूरा न होने से जुड़े दिशा-निर्देशों का पालन करें.

  • आप ConversionAction को नहीं बदल सकते बदलाव कर सकते हैं. इसके बजाय, पिछले कन्वर्ज़न को हटाने के लिए RETRACTION का इस्तेमाल करें और अपडेट किए गए ConversionAction के साथ नया कन्वर्ज़न अपलोड करें. टाइमस्टैंप में बदलाव करने की ज़रूरत नहीं है. यहां जाएं: कन्वर्ज़न के बारे में जानकारी अडजस्टमेंट.