Search in sources :

Example 1 with WebpageParameter

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

the class AddDynamicSearchAdsCampaign method addWebPageCriteria.

/**
 * Adds a web page criteria to target Dynamic Search Ads.
 */
private static void addWebPageCriteria(AdWordsServicesInterface adWordsServices, AdWordsSession session, AdGroup adGroup) throws ApiException, RemoteException {
    // Get the AdGroupCriterionService.
    AdGroupCriterionServiceInterface adGroupCriterionService = adWordsServices.get(session, AdGroupCriterionServiceInterface.class);
    // Create a webpage criterion for special offers.
    WebpageParameter param = new WebpageParameter();
    param.setCriterionName("Special offers");
    WebpageCondition urlCondition = new WebpageCondition();
    urlCondition.setOperand(WebpageConditionOperand.URL);
    urlCondition.setArgument("/specialoffers");
    WebpageCondition titleCondition = new WebpageCondition();
    titleCondition.setOperand(WebpageConditionOperand.PAGE_TITLE);
    titleCondition.setArgument("Special Offer");
    param.setConditions(new WebpageCondition[] { urlCondition, titleCondition });
    Webpage webpage = new Webpage();
    webpage.setParameter(param);
    // Create biddable ad group criterion.
    BiddableAdGroupCriterion biddableAdGroupCriterion = new BiddableAdGroupCriterion();
    biddableAdGroupCriterion.setAdGroupId(adGroup.getId());
    biddableAdGroupCriterion.setCriterion(webpage);
    biddableAdGroupCriterion.setUserStatus(UserStatus.PAUSED);
    // Optional: set a custom bid.
    BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration();
    CpcBid bid = new CpcBid();
    bid.setBid(new Money());
    bid.getBid().setMicroAmount(10000000L);
    biddingStrategyConfiguration.setBids(new Bids[] { bid });
    biddableAdGroupCriterion.setBiddingStrategyConfiguration(biddingStrategyConfiguration);
    // Create operations.
    AdGroupCriterionOperation operation = new AdGroupCriterionOperation();
    operation.setOperator(Operator.ADD);
    operation.setOperand(biddableAdGroupCriterion);
    // Create the criterion.
    AdGroupCriterion newAdGroupCriterion = adGroupCriterionService.mutate(new AdGroupCriterionOperation[] { operation }).getValue(0);
    System.out.printf("Webpage criterion with ID %d was added to ad group ID %d.%n", newAdGroupCriterion.getCriterion().getId(), newAdGroupCriterion.getAdGroupId());
}
Also used : Money(com.google.api.ads.adwords.axis.v201809.cm.Money) AdGroupCriterionOperation(com.google.api.ads.adwords.axis.v201809.cm.AdGroupCriterionOperation) Webpage(com.google.api.ads.adwords.axis.v201809.cm.Webpage) AdGroupCriterionServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.AdGroupCriterionServiceInterface) BiddableAdGroupCriterion(com.google.api.ads.adwords.axis.v201809.cm.BiddableAdGroupCriterion) BiddingStrategyConfiguration(com.google.api.ads.adwords.axis.v201809.cm.BiddingStrategyConfiguration) BiddableAdGroupCriterion(com.google.api.ads.adwords.axis.v201809.cm.BiddableAdGroupCriterion) AdGroupCriterion(com.google.api.ads.adwords.axis.v201809.cm.AdGroupCriterion) CpcBid(com.google.api.ads.adwords.axis.v201809.cm.CpcBid) WebpageParameter(com.google.api.ads.adwords.axis.v201809.cm.WebpageParameter) WebpageCondition(com.google.api.ads.adwords.axis.v201809.cm.WebpageCondition)

Example 2 with WebpageParameter

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

the class AddDynamicPageFeed method addDsaTargeting.

/**
 * Sets custom targeting for the page feed URLs based on a list of labels.
 *
 * @param adWordsServices
 * @param session
 * @param adGroupId
 * @param dsaPageUrlLabel
 */
private static void addDsaTargeting(AdWordsServicesInterface adWordsServices, AdWordsSession session, Long adGroupId, String dsaPageUrlLabel) throws ApiException, RemoteException {
    // Get the AdGroupCriterionService.
    AdGroupCriterionServiceInterface adGroupCriterionService = adWordsServices.get(session, AdGroupCriterionServiceInterface.class);
    // Create a webpage criterion.
    Webpage webpage = new Webpage();
    WebpageParameter parameter = new WebpageParameter();
    parameter.setCriterionName("Test criterion");
    webpage.setParameter(parameter);
    // Add a condition for label=specified_label_name.
    WebpageCondition condition = new WebpageCondition();
    condition.setOperand(WebpageConditionOperand.CUSTOM_LABEL);
    condition.setArgument(dsaPageUrlLabel);
    parameter.setConditions(new WebpageCondition[] { condition });
    BiddableAdGroupCriterion criterion = new BiddableAdGroupCriterion();
    criterion.setAdGroupId(adGroupId);
    criterion.setCriterion(webpage);
    // Set a custom bid for this criterion.
    BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration();
    CpcBid cpcBid = new CpcBid();
    Money money = new Money();
    money.setMicroAmount(1_500_000L);
    cpcBid.setBid(money);
    biddingStrategyConfiguration.setBids(new Bids[] { cpcBid });
    criterion.setBiddingStrategyConfiguration(biddingStrategyConfiguration);
    AdGroupCriterionOperation operation = new AdGroupCriterionOperation();
    operation.setOperand(criterion);
    operation.setOperator(Operator.ADD);
    BiddableAdGroupCriterion newCriterion = (BiddableAdGroupCriterion) adGroupCriterionService.mutate(new AdGroupCriterionOperation[] { operation }).getValue(0);
    System.out.printf("Web page criterion with ID %d and status '%s' was created.%n", newCriterion.getCriterion().getId(), newCriterion.getUserStatus());
}
Also used : Money(com.google.api.ads.adwords.axis.v201809.cm.Money) AdGroupCriterionOperation(com.google.api.ads.adwords.axis.v201809.cm.AdGroupCriterionOperation) Webpage(com.google.api.ads.adwords.axis.v201809.cm.Webpage) AdGroupCriterionServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.AdGroupCriterionServiceInterface) BiddableAdGroupCriterion(com.google.api.ads.adwords.axis.v201809.cm.BiddableAdGroupCriterion) BiddingStrategyConfiguration(com.google.api.ads.adwords.axis.v201809.cm.BiddingStrategyConfiguration) CpcBid(com.google.api.ads.adwords.axis.v201809.cm.CpcBid) WebpageParameter(com.google.api.ads.adwords.axis.v201809.cm.WebpageParameter) WebpageCondition(com.google.api.ads.adwords.axis.v201809.cm.WebpageCondition)

Aggregations

AdGroupCriterionOperation (com.google.api.ads.adwords.axis.v201809.cm.AdGroupCriterionOperation)2 AdGroupCriterionServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.AdGroupCriterionServiceInterface)2 BiddableAdGroupCriterion (com.google.api.ads.adwords.axis.v201809.cm.BiddableAdGroupCriterion)2 BiddingStrategyConfiguration (com.google.api.ads.adwords.axis.v201809.cm.BiddingStrategyConfiguration)2 CpcBid (com.google.api.ads.adwords.axis.v201809.cm.CpcBid)2 Money (com.google.api.ads.adwords.axis.v201809.cm.Money)2 Webpage (com.google.api.ads.adwords.axis.v201809.cm.Webpage)2 WebpageCondition (com.google.api.ads.adwords.axis.v201809.cm.WebpageCondition)2 WebpageParameter (com.google.api.ads.adwords.axis.v201809.cm.WebpageParameter)2 AdGroupCriterion (com.google.api.ads.adwords.axis.v201809.cm.AdGroupCriterion)1