Search in sources :

Example 1 with OfflineConversionAdjustmentFeedOperation

use of com.google.api.ads.adwords.axis.v201809.cm.OfflineConversionAdjustmentFeedOperation in project googleads-java-lib by googleads.

the class UploadConversionAdjustment method runExample.

/**
 * Runs the example.
 *
 * @param adWordsServices the services factory.
 * @param session the session.
 * @param conversionName the name of the conversion tracker.
 * @param gclId the GCLID for the conversion.
 * @param adjustmentType the type of adjustment.
 * @param adjustmentTime the date and time of the adjustment.
 * @param conversionTime the date and time of the conversion.
 * @param adjustedValue the adjusted value.
 * @throws ApiException if the API request failed with one or more service errors.
 * @throws RemoteException if the API request failed due to other errors.
 */
public static void runExample(AdWordsServicesInterface adWordsServices, AdWordsSession session, String conversionName, String gclId, OfflineConversionAdjustmentType adjustmentType, String conversionTime, String adjustmentTime, @Nullable Double adjustedValue) throws RemoteException {
    // Get the OfflineConversionAdjustmentFeedService.
    OfflineConversionAdjustmentFeedServiceInterface offlineConversionFeedService = adWordsServices.get(session, OfflineConversionAdjustmentFeedServiceInterface.class);
    // Associate conversion adjustments with the existing named conversion tracker. The GCLID should
    // have been uploaded before with a conversion.
    GclidOfflineConversionAdjustmentFeed feed = new GclidOfflineConversionAdjustmentFeed();
    feed.setConversionName(conversionName);
    feed.setAdjustmentType(adjustmentType);
    feed.setConversionTime(conversionTime);
    feed.setAdjustmentTime(adjustmentTime);
    feed.setAdjustedValue(adjustedValue);
    feed.setGoogleClickId(gclId);
    OfflineConversionAdjustmentFeedOperation offlineConversionOperation = new OfflineConversionAdjustmentFeedOperation();
    offlineConversionOperation.setOperator(Operator.ADD);
    offlineConversionOperation.setOperand(feed);
    OfflineConversionAdjustmentFeedReturnValue offlineConversionReturnValue = offlineConversionFeedService.mutate(new OfflineConversionAdjustmentFeedOperation[] { offlineConversionOperation });
    for (OfflineConversionAdjustmentFeed newFeed : offlineConversionReturnValue.getValue()) {
        System.out.printf("Uploaded conversion adjusted value of %.4f for Google Click ID '%s'.%n", newFeed.getAdjustedValue(), ((GclidOfflineConversionAdjustmentFeed) newFeed).getGoogleClickId());
    }
}
Also used : OfflineConversionAdjustmentFeedServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.OfflineConversionAdjustmentFeedServiceInterface) OfflineConversionAdjustmentFeedOperation(com.google.api.ads.adwords.axis.v201809.cm.OfflineConversionAdjustmentFeedOperation) OfflineConversionAdjustmentFeedReturnValue(com.google.api.ads.adwords.axis.v201809.cm.OfflineConversionAdjustmentFeedReturnValue) GclidOfflineConversionAdjustmentFeed(com.google.api.ads.adwords.axis.v201809.cm.GclidOfflineConversionAdjustmentFeed) OfflineConversionAdjustmentFeed(com.google.api.ads.adwords.axis.v201809.cm.OfflineConversionAdjustmentFeed) GclidOfflineConversionAdjustmentFeed(com.google.api.ads.adwords.axis.v201809.cm.GclidOfflineConversionAdjustmentFeed)

Aggregations

GclidOfflineConversionAdjustmentFeed (com.google.api.ads.adwords.axis.v201809.cm.GclidOfflineConversionAdjustmentFeed)1 OfflineConversionAdjustmentFeed (com.google.api.ads.adwords.axis.v201809.cm.OfflineConversionAdjustmentFeed)1 OfflineConversionAdjustmentFeedOperation (com.google.api.ads.adwords.axis.v201809.cm.OfflineConversionAdjustmentFeedOperation)1 OfflineConversionAdjustmentFeedReturnValue (com.google.api.ads.adwords.axis.v201809.cm.OfflineConversionAdjustmentFeedReturnValue)1 OfflineConversionAdjustmentFeedServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.OfflineConversionAdjustmentFeedServiceInterface)1