Search in sources :

Example 1 with ExpandedDynamicSearchAd

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

the class AddDynamicSearchAdsCampaign method createExpandedDSA.

/**
 * Creates the expanded Dynamic Search Ad.
 */
private static void createExpandedDSA(AdWordsServicesInterface adWordsServices, AdWordsSession session, AdGroup adGroup) throws ApiException, RemoteException {
    // Get the AdGroupAdService.
    AdGroupAdServiceInterface adGroupAdService = adWordsServices.get(session, AdGroupAdServiceInterface.class);
    // Create the expanded Dynamic Search Ad. This ad will have its headline and final URL
    // auto-generated at serving time according to domain name specific information provided
    // by DynamicSearchAdsSetting at the campaign level.
    ExpandedDynamicSearchAd expandedDSA = new ExpandedDynamicSearchAd();
    // Set the ad description.
    expandedDSA.setDescription("Buy your tickets now!");
    expandedDSA.setDescription2("Discount ends soon");
    // Create the ad group ad.
    AdGroupAd adGroupAd = new AdGroupAd();
    adGroupAd.setAdGroupId(adGroup.getId());
    adGroupAd.setAd(expandedDSA);
    // Optional: Set the status.
    adGroupAd.setStatus(AdGroupAdStatus.PAUSED);
    // Create the operation.
    AdGroupAdOperation operation = new AdGroupAdOperation();
    operation.setOperator(Operator.ADD);
    operation.setOperand(adGroupAd);
    // Create the ad.
    AdGroupAd newAdGroupAd = adGroupAdService.mutate(new AdGroupAdOperation[] { operation }).getValue(0);
    ExpandedDynamicSearchAd newExpandedDSA = (ExpandedDynamicSearchAd) newAdGroupAd.getAd();
    System.out.printf("Expanded Dynamic Search Ad with ID %d and description '%s' and description 2 '%s' was " + "added.%n", newExpandedDSA.getId(), newExpandedDSA.getDescription(), newExpandedDSA.getDescription2());
}
Also used : AdGroupAd(com.google.api.ads.adwords.axis.v201809.cm.AdGroupAd) AdGroupAdServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.AdGroupAdServiceInterface) AdGroupAdOperation(com.google.api.ads.adwords.axis.v201809.cm.AdGroupAdOperation) ExpandedDynamicSearchAd(com.google.api.ads.adwords.axis.v201809.cm.ExpandedDynamicSearchAd)

Aggregations

AdGroupAd (com.google.api.ads.adwords.axis.v201809.cm.AdGroupAd)1 AdGroupAdOperation (com.google.api.ads.adwords.axis.v201809.cm.AdGroupAdOperation)1 AdGroupAdServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.AdGroupAdServiceInterface)1 ExpandedDynamicSearchAd (com.google.api.ads.adwords.axis.v201809.cm.ExpandedDynamicSearchAd)1