Stay organized with collectionsSave and categorize content based on your preferences.
Once a conversion has already been reported to Google Ads, you canadjust the
conversionat a later point in
time in the Google Ads API.
In order to adjust a conversion, you must first have a conversion actionset
up, and you must also have
recorded the conversions that you are about to adjust.
defmain(client:GoogleAdsClient,customer_id:str,conversion_action_id:str,adjustment_type:str,order_id:str,adjustment_date_time:str,restatement_value:Optional[str]=None,)->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 theadjustment to.adjustment_type: the adjustment type, e.g. " "RETRACTION, RESTATEMENT.order_id: the transaction ID of the conversion to adjust. Stronglyrecommended 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:ConversionAdjustmentTypeEnum=(client.enums.ConversionAdjustmentTypeEnum)# Determine the adjustment type.conversion_adjustment_type:int=conversion_adjustment_type_enum[adjustment_type].value# Applies the conversion adjustment to the existing conversion.conversion_adjustment:ConversionAdjustment=client.get_type("ConversionAdjustment")conversion_action_service:ConversionActionServiceClient=(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_typeconversion_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_valueandconversion_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:ConversionAdjustmentUploadServiceClient=client.get_service("ConversionAdjustmentUploadService")request:UploadConversionAdjustmentsRequest=client.get_type("UploadConversionAdjustmentsRequest")request.customer_id=customer_idrequest.conversion_adjustments.append(conversion_adjustment)# Enables partial failure (must be true)request.partial_failure=Trueresponse:UploadConversionAdjustmentsResponse=(service.upload_conversion_adjustments(request=request))# Extracts the partial failure error if present on the response.error_details=Noneifresponse.partial_failure_error:error_details:Iterable[Any]=response.partial_failure_error.detailsi:intconversion_adjustment_result:ConversionAdjustmentResultfori,conversion_adjustment_resultinenumerate(response.results):# If there's a GoogleAdsFailure in error_details at this position then# the uploaded operation failed and we print the error message.iferror_detailsanderror_details[i]:error_detail:Any=error_details[i]failure_message:GoogleAdsFailure=client.get_type("GoogleAdsFailure")# Parse the string into a GoogleAdsFailure message instance.# To access class-only methods on the message we retrieve its type.google_ads_failure_class:GoogleAdsFailure=type(failure_message)failure_object:GoogleAdsFailure=(google_ads_failure_class.deserialize(error_detail.value))error:GoogleAdsErrorforerrorinfailure_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}'.")
defupload_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 parametersclient=Google::Ads::GoogleAds::GoogleAdsClient.new# Applies the conversion adjustment to the existing conversion.conversion_adjustment=client.resource.conversion_adjustmentdo|ca|ca.conversion_action=client.path.conversion_action(customer_id,conversion_action_id)ca.adjustment_type=adjustment_typeca.order_id=order_idca.adjustment_date_time=adjustment_date_time# Set adjusted value for adjustment type RESTATEMENT.ifadjustment_type==:RESTATEMENTca.restatement_value=client.resource.restatement_valuedo|ra|ra.adjusted_value=restatement_value.to_fendendend# 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)ifresponse.partial_failure_error.nil?# Process and print all results for multiple adjustmentsresponse.results.eachdo|result|puts"Uploaded conversion adjustment for conversion action#{result.conversion_action}"\"and order ID#{result.order_id}."endelse# Print any partial errors returned.failures=client.decode_partial_failure_error(response.partial_failure_error)puts'Request failed. Failure details:'failures.eachdo|failure|failure.errors.eachdo|error|index=error.location.field_path_elements.first.indexputs"\toperation[#{index}]#{error.error_code.error_code}:#{error.message}"endendendend
subupload_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::V21::Services::ConversionAdjustmentUploadService::ConversionAdjustment->new({conversionAction=>Google::Ads::GoogleAds::V21::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::V21::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::V21::Services::ConversionAdjustmentUploadService::RestatementValue->new({adjustedValue=>$restatement_value})ifdefined$restatement_value&&$adjustment_typeeqRESTATEMENT;# 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};}return1;}
Here are some requirements and restrictions to keep in mind while adjusting
conversions in the API:
Only the account that manages conversion actions is able to import
adjustments. Use theconversion tracking setup instructionsto determine which account is managing conversions for your Google Ads account.
Attempting to import an adjustment using a different account results in aNO_CONVERSION_ACTION_FOUNDerror. This error also occurs if the conversion action of the adjustment is
not enabled.
Google Ads only supports adjusting conversions for conversion action types ofSALESFORCE,UPLOAD_CLICKS, orWEBPAGE. Attempting to import an
adjustment for a conversion where the conversion action is not one of these
types results in anINVALID_CONVERSION_ACTION_TYPEerror.
The fields specifying date and time require aselected timezonewhich can be different than the account's time zone. The format of these
fields is asyyyy-mm-dd HH:mm:ss+|-HH:mm, for example:2022-01-01 19:32:45-05:00(ignoring daylight saving time)
.
Wait 4 to 6 hours after creating the conversion action before adjusting its
conversions to avoid aTOO_RECENT_CONVERSION_ACTIONerror.
The adjustment fails with aCONVERSION_NOT_FOUNDerror if the conversion was never imported, or was imported, but discarded
due to being deemed invalid or spam.
You must specify theorder_idin theConversionAdjustmentunder any of
these conditions:
Thetypeof the conversion action is equal toWEBPAGE.
The original conversion you are adjusting was assigned anorder_id.
If you specify thegclid_date_time_pairinstead, the operation will
fail with aConversionAdjustmentUploadError.MISSING_ORDER_ID_FOR_WEBPAGEorConversionAdjustmentUploadError.CONVERSION_NOT_FOUNDerror,
respectively.
You cannot change theConversionActionassigned to a conversion with an adjustment. Instead, use aRETRACTIONto remove the previous conversion and import a new conversion with the
updatedConversionAction. The timestamp does not need to be modified. SeeAbout conversion adjustmentsfor more information.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-03 UTC."],[[["\u003cp\u003eThe Google Ads API allows for adjustments to previously reported conversions using methods like \u003ccode\u003eorder_id\u003c/code\u003e or \u003ccode\u003egclid_date_time_pair\u003c/code\u003e, with \u003ccode\u003eorder_id\u003c/code\u003e being the preferred and most reliable identifier.\u003c/p\u003e\n"],["\u003cp\u003eAdjustments can be made using \u003ccode\u003eRETRACTION\u003c/code\u003e to remove a conversion or \u003ccode\u003eRESTATEMENT\u003c/code\u003e to modify its value, requiring the original conversion action to be set up correctly.\u003c/p\u003e\n"],["\u003cp\u003eSeveral limitations exist, including specific conversion action types that are supported, time constraints after creating a conversion action, and mandatory \u003ccode\u003eorder_id\u003c/code\u003e for webpage conversions when initially provided.\u003c/p\u003e\n"],["\u003cp\u003eProper error handling is crucial, as adjustments might fail due to various reasons like incorrect account usage, invalid original conversions, or missing mandatory fields, necessitating the use of \u003ccode\u003epartial_failure\u003c/code\u003e for robust implementation.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers should understand the prerequisites, limitations, and potential errors associated with conversion adjustments to ensure accurate and effective tracking of advertising performance in Google Ads.\u003c/p\u003e\n"]]],[],null,[]]