Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.google.ads.googleads.v9.services.ConversionAdjustment;
import com.google.ads.googleads.v9.services.ConversionAdjustmentResult;
import com.google.ads.googleads.v9.services.ConversionAdjustmentUploadServiceClient;
import com.google.ads.googleads.v9.services.GclidDateTimePair;
import com.google.ads.googleads.v9.services.RestatementValue;
import com.google.ads.googleads.v9.services.UploadConversionAdjustmentsRequest;
import com.google.ads.googleads.v9.services.UploadConversionAdjustmentsResponse;
Expand All @@ -53,6 +54,16 @@ private static class UploadConversionEnhancementParams extends CodeSampleParams
@Parameter(names = ArgumentNames.ORDER_ID, required = true)
private String orderId;

@Parameter(
names = ArgumentNames.CONVERSION_DATE_TIME,
required = false,
description =
"The date time at which the conversion with the specified order ID occurred. "
+ "Must be after the click time, and must include the time zone offset. "
+ "The format is 'yyyy-mm-dd hh:mm:ss+|-hh:mm', e.g. '2019-01-01 12:32:45-08:00'. "
+ "Setting this field is optional, but recommended.")
private String conversionDateTime;

@Parameter(names = ArgumentNames.USER_AGENT, required = false)
private String userAgent;

Expand All @@ -77,7 +88,9 @@ public static void main(String[] args)
params.conversionActionId = Long.parseLong("INSERT_CONVERSION_ACTION_ID_HERE");
params.orderId = "INSERT_ORDER_ID_HERE";

// Optional: Specify the user agent, restatement value and restatement currency code.
// Optional: Specify the conversion date/time, user agent, restatement value, and restatement
// currency code.
params.conversionDateTime = null;
params.userAgent = null;
params.restatementValue = null;
params.currencyCode = null;
Expand All @@ -102,6 +115,7 @@ public static void main(String[] args)
params.customerId,
params.conversionActionId,
params.orderId,
params.conversionDateTime,
params.userAgent,
params.restatementValue,
params.currencyCode);
Expand All @@ -128,6 +142,7 @@ public static void main(String[] args)
* @param customerId the client customer ID.
* @param conversionActionId conversion action ID associated with this conversion.
* @param orderId unique order ID (transaction ID) of the conversion.
* @param conversionDateTime
* @param userAgent the HTTP user agent of the conversion.
* @param restatementValue the enhancement value.
* @param restatementCurrencyCode the currency of the enhancement value.
Expand All @@ -138,6 +153,7 @@ private void runExample(
long customerId,
long conversionActionId,
String orderId,
String conversionDateTime,
String userAgent,
Double restatementValue,
String restatementCurrencyCode)
Expand All @@ -151,6 +167,13 @@ private void runExample(
// Enhancements MUST use order ID instead of GCLID date/time pair.
.setOrderId(orderId);

// Sets the conversion date and time if provided. Providing this value is optional but
// recommended.
if (conversionDateTime != null) {
enhancementBuilder.setGclidDateTimePair(
GclidDateTimePair.newBuilder().setConversionDateTime(conversionDateTime));
}

// Creates a SHA256 message digest for hashing user identifiers in a privacy-safe way, as
// described at https://support.google.com/google-ads/answer/9888656.
MessageDigest sha256Digest = MessageDigest.getInstance("SHA-256");
Expand Down