@@ -87,6 +87,14 @@ private static class UploadStoreSalesTransactionsParams extends CodeSampleParams
8787 required = true ,
8888 description = "The ID of a store sales conversion action" )
8989 private Long conversionActionId ;
90+
91+ @ Parameter (
92+ names = ArgumentNames .CUSTOM_KEY ,
93+ required = false ,
94+ description = "Only required after creating a custom key and custom values in the account."
95+ + " Custom key and values are used to segment store sales conversions."
96+ + " This measurement can be used to provide more advanced insights." )
97+ private String customKey ;
9098
9199 @ Parameter (
92100 names = ArgumentNames .ADVERTISER_UPLOAD_DATE_TIME ,
@@ -118,6 +126,8 @@ public static void main(String[] args)
118126 params .conversionActionId = Long .parseLong ("INSERT_CONVERSION_ACTION_ID_HERE" );
119127 // OPTIONAL (but recommended): Specify an external ID for the job.
120128 // params.externalId = Long.parseLong("INSERT_EXTERNAL_ID_HERE");
129+ // OPTIONAL: If uploading data with custom key and values, also specify the following value:
130+ // params.customKey = "INSERT_CUSTOM_KEY_HERE";
121131 // OPTIONAL: If uploading third party data, also specify the following values:
122132 // params.advertiserUploadDateTime = "INSERT_ADVERTISER_UPLOAD_DATE_TIME_HERE";
123133 // params.bridgeMapVersionId = "INSERT_BRIDGE_MAP_VERSION_ID_HERE";
@@ -144,6 +154,7 @@ public static void main(String[] args)
144154 params .offlineUserDataJobType ,
145155 params .externalId ,
146156 params .conversionActionId ,
157+ params .customKey ,
147158 params .advertiserUploadDateTime ,
148159 params .bridgeMapVersionId ,
149160 params .partnerId );
@@ -172,6 +183,8 @@ public static void main(String[] args)
172183 * STORE_SALES_UPLOAD_THIRD_PARTY}. Otherwise, use {@code STORE_SALES_UPLOAD_FIRST_PARTY}.
173184 * @param externalId optional (but recommended) external ID for the offline user data job.
174185 * @param conversionActionId the ID of a store sales conversion action.
186+ * @param customKey to segment store sales conversions. Only required after creating a
187+ * custom key and custom values in the account.
175188 * @param advertiserUploadDateTime date and time the advertiser uploaded data to the partner. Only
176189 * required for third party uploads.
177190 * @param bridgeMapVersionId version of partner IDs to be used for uploads. Only required for
@@ -185,6 +198,7 @@ private void runExample(
185198 OfflineUserDataJobType offlineUserDataJobType ,
186199 Long externalId ,
187200 long conversionActionId ,
201+ String customKey ,
188202 String advertiserUploadDateTime ,
189203 String bridgeMapVersionId ,
190204 Long partnerId )
@@ -200,6 +214,7 @@ private void runExample(
200214 customerId ,
201215 offlineUserDataJobType ,
202216 externalId ,
217+ customKey ,
203218 advertiserUploadDateTime ,
204219 bridgeMapVersionId ,
205220 partnerId );
@@ -235,6 +250,7 @@ private String createOfflineUserDataJob(
235250 long customerId ,
236251 OfflineUserDataJobType offlineUserDataJobType ,
237252 Long externalId ,
253+ String customKey ,
238254 String advertiserUploadDateTime ,
239255 String bridgeMapVersionId ,
240256 Long partnerId ) {
@@ -258,6 +274,10 @@ private String createOfflineUserDataJob(
258274 // you are uploading all 70 of the transactions that can be identified by an email
259275 // address or phone number.
260276 .setTransactionUploadFraction (DoubleValue .of (1.0 ));
277+
278+ if (customKey != null && !customKey .isEmpty ()) {
279+ storeSalesMetadataBuilder .setCustomKey (StringValue .of (customKey ));
280+ }
261281
262282 if (OfflineUserDataJobType .STORE_SALES_UPLOAD_THIRD_PARTY == offlineUserDataJobType ) {
263283 // Creates additional metadata required for uploading third party data.
@@ -401,7 +421,10 @@ private List<OfflineUserDataJobOperation> buildOfflineUserDataJobOperations(
401421 // Specifies the date and time of the transaction. This date and time will be
402422 // interpreted by the API using the Google Ads customer's time zone.
403423 // The date/time must be in the format "yyyy-MM-dd hh:mm:ss".
404- .setTransactionDateTime (StringValue .of ("2020-05-01 23:52:12" )))
424+ .setTransactionDateTime (StringValue .of ("2020-05-01 23:52:12" ))
425+ // OPTIONAL: If uploading data with custom key and values, also specify the following value:
426+ // .setCustomValue(StringValue.of("INSERT_CUSTOM_VALUE_HERE"))
427+ )
405428 .build ();
406429
407430 // Creates the second transaction for upload based on a physical address.
@@ -428,7 +451,10 @@ private List<OfflineUserDataJobOperation> buildOfflineUserDataJobOperations(
428451 // Specifies the date and time of the transaction. This date and time will be
429452 // interpreted by the API using the Google Ads customer's time zone.
430453 // The date/time must be in the format "yyyy-MM-dd hh:mm:ss".
431- .setTransactionDateTime (StringValue .of ("2020-05-14 19:07:02" )))
454+ .setTransactionDateTime (StringValue .of ("2020-05-14 19:07:02" ))
455+ // OPTIONAL: If uploading data with custom key and values, also specify the following value:
456+ // .setCustomValue(StringValue.of("INSERT_CUSTOM_VALUE_HERE"))
457+ )
432458 .build ();
433459
434460 // Creates the operations to add the two transactions.
0 commit comments