// Get the ConversionTrackerService.
ConversionTrackerServiceInterface service =
adWordsServices.get(session, ConversionTrackerServiceInterface.class);
// Create AdWords conversion.
AdWordsConversionTracker adWordsConversionTracker = new AdWordsConversionTracker();
adWordsConversionTracker.setName("Earth to Mars Cruises Conversion # "
+ System.currentTimeMillis());
adWordsConversionTracker.setCategory(ConversionTrackerCategory.DEFAULT);
adWordsConversionTracker.setMarkupLanguage(AdWordsConversionTrackerMarkupLanguage.HTML);
adWordsConversionTracker.setTextFormat(AdWordsConversionTrackerTextFormat.HIDDEN);
// You can optionally provide these field(s).
adWordsConversionTracker.setStatus(ConversionTrackerStatus.ENABLED);
adWordsConversionTracker.setViewthroughLookbackWindow(15);
adWordsConversionTracker.setIsProductAdsChargeable(Boolean.TRUE);
adWordsConversionTracker.setProductAdsChargeableConversionWindow(15);
adWordsConversionTracker.setConversionPageLanguage("en");
adWordsConversionTracker.setBackgroundColor("#0000FF");
adWordsConversionTracker.setDefaultRevenueValue(1d);
adWordsConversionTracker.setAlwaysUseDefaultRevenueValue(Boolean.TRUE);
// Create operations.
ConversionTrackerOperation operation = new ConversionTrackerOperation();
operation.setOperator(Operator.ADD);
operation.setOperand(adWordsConversionTracker);
ConversionTrackerOperation[] operations = new ConversionTrackerOperation[] {operation};
// Add conversion.
ConversionTrackerReturnValue result = service.mutate(operations);
// Display conversion.
for (ConversionTracker conversionTracker : result.getValue()) {
if (conversionTracker instanceof AdWordsConversionTracker) {
AdWordsConversionTracker newAdWordsConversionTracker =
(AdWordsConversionTracker) conversionTracker;
System.out.printf("Conversion with id \"%d\", name \"%s\", status \"%s\", "
+ "category \"%s\" and snippet \"%s\" was added.\n",
newAdWordsConversionTracker.getId(), newAdWordsConversionTracker.getName(),
newAdWordsConversionTracker.getStatus(), newAdWordsConversionTracker.getCategory(),
newAdWordsConversionTracker.getSnippet());
} else {
System.out.printf("Conversion with id \"%d\", name \"%s\", status \"%s\", "
+ "category \"%s\" was added.\n", conversionTracker.getId(),
conversionTracker.getName(), conversionTracker.getStatus(),
conversionTracker.getCategory());